oauth - Error on making POST request to EBay API in R -


im trying ebay oauth token , refresh tokens in r. sticked following tutorial:

ebay oauth token , refresh tokens

how post api in r having header & json body

i trying same procedure above in r end getting "invalid_client" error while perfoming post request refresh token.

here code:

library(httr) library(jsonlite)  url="https://api.sandbox.ebay.com/identity/v1/oauth2/token" clientid<-"xxxxqe-testapp-sbx-98e06383e-2c48398a" clientsecret<-"sbx-8e06383effa2-a7d9-4415-b7ec-4c5c" secret<-base64_enc(paste(clientid,clientsecret,sep = ":"))  bodylist<-list(grant_type="authorization_code",                code="v%5e1.1%23i%5e1%23f%5e0%23r%5e1%23i%5e3%23p%5e3%23t%5eul4xxzq5otrdrui5mjrcnui0njm2qjq2mdrdn0iwquqwodvgxzjfmsnfxjeyodq%3d",                redirect_uri="xxxxq_***-xxxxqe-testap-hzuebr")   y<-post(url=url,verbose=true,         add_headers("content-type"="application/x-www-form-urlencoded",                     authorization=paste("basic", gsub("\n", "", secret),sep=" ")),         body =  bodylist,         encode = "form") y content(y) y$request 

here get:

> content(y) $error [1] "invalid_grant"  $error_description [1] "the provided authorization grant code invalid or issued client"  > y$request <request>   post https://api.sandbox.ebay.com/identity/v1/oauth2/token output: write_memory options:   * useragent: libcurl/7.54.1 r-curl/2.8.1 httr/1.3.0 * cainfo: c:/progra~1/r/r-33~1.3/etc/curl-ca-bundle.crt * post: true * postfieldsize: 233 * postfields: as.raw(c(0x67, 0x72, 0x61, 0x6e, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x26, 0x63, 0x6f, 0x64, 0x65, 0x3d, 0x76, 0x25, 0x32, 0x35, 0x35, 0x45, 0x31, 0x2e, 0x31, 0x25, 0x32, 0x35, 0x32, 0x33, 0x69, 0x25, 0x32, 0x35, 0x35, 0x45, 0x31, 0x25, 0x32, 0x35, 0x32, 0x33, 0x66, 0x25, 0x32, 0x35, 0x35, 0x45, 0x30, 0x25, 0x32, 0x35, 0x32, 0x33, 0x72, 0x25, 0x32, 0x35, 0x35, 0x45, 0x31, 0x25, 0x32,                         0x35, 0x32, 0x33, 0x49, 0x25, 0x32, 0x35, 0x35, 0x45, 0x33, 0x25, 0x32, 0x35, 0x32, 0x33, 0x70, 0x25, 0x32, 0x35, 0x35, 0x45, 0x33, 0x25, 0x32, 0x35, 0x32, 0x33, 0x74, 0x25, 0x32, 0x35, 0x35, 0x45, 0x55, 0x6c, 0x34, 0x78, 0x58, 0x7a, 0x51, 0x35, 0x4f, 0x54, 0x52, 0x44, 0x52, 0x55, 0x49, 0x35, 0x4d, 0x6a, 0x52, 0x43, 0x4e, 0x55, 0x49, 0x30, 0x4e, 0x6a, 0x4d, 0x32, 0x51, 0x6a, 0x51, 0x32, 0x4d, 0x44, 0x52, 0x44, 0x4e, 0x30, 0x49, 0x77, 0x51, 0x55, 0x51, 0x77, 0x4f, 0x44, 0x56, 0x47, 0x58, 0x7a, 0x4a,                         0x66, 0x4d, 0x53, 0x4e, 0x46, 0x58, 0x6a, 0x45, 0x79, 0x4f, 0x44, 0x51, 0x25, 0x32, 0x35, 0x33, 0x44, 0x26, 0x72, 0x65, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x5f, 0x75, 0x72, 0x69, 0x3d, 0x44, 0x65, 0x6e, 0x6e, 0x69, 0x73, 0x71, 0x5f, 0x45, 0x75, 0x70, 0x65, 0x72, 0x2d, 0x44, 0x65, 0x6e, 0x6e, 0x69, 0x73, 0x71, 0x45, 0x2d, 0x74, 0x65, 0x73, 0x74, 0x61, 0x70, 0x2d, 0x68, 0x7a, 0x75, 0x65, 0x62, 0x72)) headers:   * accept: application/json, text/xml, application/xml, */*   * content-type: application/x-www-form-urlencoded * authorization: basic rgvubmlzcuutdgvzdgfwcc1tqlgtothlmdyzodnlltjjndgzothholncwc04zta2mzgzzwzmytitytdkos00nde1lwi3zwmtngm1yw== 

what not sure base64 encoding. returns me someting "/n". correct replace "/n"?

i wondering this:

headers:   * accept: application/json, text/xml, application/xml, */* 

how accept-header come in here?

im looking foward advice.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -