Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Generating an OAuth Token - Steps using R

Status
Not open for further replies.

BxWill

MIS
Mar 30, 2009
367
US
Appreciate some timely insight!

Novice - first time attempting to extract data via an API.

I obtained a API Key and the Secret.

Converted to base64.

Now perplexed as to the next step where the instructions that I have state that I should "Enter the generated base64value in the header and request body and call the token URI as shown below;

Code:
Authorization: Basic {base64value} 
Content-Type: application/x-[URL unfurl="true"]www-form-urlencoded[/URL] 
POST [URL unfurl="true"]https://api.destination.com/oauth/token[/URL]
grant_type=client_credentials

Any insight as to if R can be used to obtain the OAuth Token?

If so, what are the required packages that I need to install?


Thanks in advance.
 
Any insight as to the resolution of a status code of 401 using the R code below?

Attempting to generate an oauth token.

Thanks in advance.

Code:
library(httr)

base64_value <-
  "123456789="
  

response16 <-
  httr::POST (url = "[URL unfurl="true"]https://api.precisely.com/oauth/token"[/URL] , 
             httr::add_headers(Authorization = paste("Basic", base64_value, sep = "")),
             body = list(grant_type = "client_credentials"),
             encode = "form"
             )

#verbose(data_out = true, data_in = False, info = false, ssl = false)


warn_for_status(response16)
stop_for_status(response16)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top