Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library(httr)
- library(base64enc)
- library(jsonlite)
- url<-"https://api.ebay.com/identity/v1/oauth2/token"
- clientID<-"****-testapp-******-*****"
- clientSecret<-"PRD-8********-***-***-****-****"
- base64encode(paste(clientID,clientSecret,sep = ":"))
- request_body <- data.frame(
- code="v%5E1.1%23i%5E1%23I%5E3%23r%5E1%23p%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
- grant_type="authorization_code",
- redirect_uri="*****-*****-testap-******"
- )
- ##Approach 1##
- result <- POST(url=url,
- body = request_body,
- add_headers(.headers = c("Content-Type"="application/x-www-form-urlencoded",
- "Authorization"="Basic ******************...*****YQ=="
- )))
- Output <- content(result)
- ##Approach 2##
- request_body_json <- toJSON(list(documents = request_body), auto_unbox = TRUE)
- result <- POST(url=url,
- body = request_body_json,
- add_headers(.headers = c("Content-Type"="application/x-www-form-urlencoded",
- "Authorization"="Basic ******************...*****YQ=="
- )))
- Output <- content(result)
- result
- Output <- content(result)
- Output
- > result <- POST(url=url,
- + body = request_body,
- + add_headers(.headers = c("Content-Type"="application/x-www-form-urlencoded",
- + "Authorization"="Basic RGVubmlzRXUtdGVzdGFwcC1QUkQtMzhlMzVjNTM1LWFjNzdjODE5OlBSRC04ZTM1YzUzNTFiNzktN2UwMS00YzMxLWE0YTQtM2U5YQ=="
- + )))
- Fehler in curl::handle_setform(handle, .list = req$fields) :
- Insupported value type for form field 'code'.
- > Output <- content(result)
- > Output
- $error
- [1] "unsupported_grant_type"
- $error_description
- [1] "grant type in request is not supported by the authorization server"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement