pablobarbera / instaR

Dev version of instaR package: Access to Instagram API via R
106 stars 47 forks source link

http error 400 bad request when trying to get a token #37

Closed stedogin closed 7 years ago

stedogin commented 7 years ago

i've been trying to use instaR, but failed at getting an access token - getting the response:

Authentication complete. Error in init_oauth2.0(self$endpoint, self$app, scope = self$params$scope, : Bad Request (HTTP 400). Failed to get an access token.

when examining the request using with_verbose(), i don't see any additional info. httr::with_verbose(my_oauth <- instaOAuth(app_id=client_id, app_secret=client_secret))

Waiting for authentication in browser... Press Esc/Ctrl + C to abort Authentication complete. POST /oauth/access_token HTTP/1.1 Host: api.instagram.com User-Agent: libcurl/7.43.0 r-curl/2.2 httr/1.2.1 Accept-Encoding: gzip, deflate Cookie: csrftoken=oLgx7eQh8uZH1ZWMl53lC2y0JJWQkmwd Accept: application/json, text/xml, application/xml, / Content-Type: application/x-www-form-urlencoded Content-Length: 206

client_id=CLIENT_ID&redirect_uri=http%3A%2F%2Flocalhost%3A141>0%2F%2F&grant_type=authorization_code&code=98e38f8c53354a22bd3786f96cd19e3e&client_secret=CLIENT_SECRET

<- HTTP/1.1 400 Bad Request <- Cache-Control: private, no-cache, no-store, must-revalidate <- Vary: Cookie, Accept-Language <- Content-Language: en <- Date: Mon, 21 Nov 2016 00:27:48 GMT <- Content-Type: application/json <- Pragma: no-cache <- Expires: Sat, 01 Jan 2000 00:00:00 GMT <- Set-Cookie: csrftoken=oLgx7eQh8uZH1ZWMl53lC2y0JJWQkmwd; expires=Mon, 20-Nov->2017 00:27:48 GMT; Max-Age=31449600; Path=/; Secure <- Connection: keep-alive <- Content-Length: 114 <- Error in init_oauth2.0(self$endpoint, self$app, scope = self$params$scope, : Bad Request (HTTP 400). Failed to get an access token.

i saw people reporting similar issues with R FB libraries, some of them reported that reverting to an older httr version resolved the issue (due to the current version possibly having some issues with http instead of https requests).

R version 3.2.3 (2015-12-10) Platform: x86_64-apple-darwin13.4.0 (64-bit) Running under: OS X 10.11.1 (El Capitan)

locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] instaR_0.2.4 jsonlite_1.1 httr_1.2.1

loaded via a namespace (and not attached): [1] R6_2.1.2 tools_3.2.3 withr_1.0.1 curl_2.2 memoise_1.0.0 Rcpp_0.12.4 >git2r_0.14.0 digest_0.6.9 httpuv_1.3.3
[10] devtools_1.11.1

stedogin commented 7 years ago

found some interesting info here, but no solution https://github.com/hadley/httr/issues/379

chcariou commented 7 years ago

i've the same problem and i have not been able to solve the problem with the link hadley/httr#379

pablobarbera commented 7 years ago

@chcariou Could you share your sessionInfo() ? I haven't been able to replicate this error, so it's hard for me to understand what could be happening!

chcariou commented 7 years ago

essionInfo() R version 3.3.2 (2016-10-31) Platform: x86_64-apple-darwin13.4.0 (64-bit) Running under: OS X El Capitan 10.11.6

locale: [1] fr_FR.UTF-8/fr_FR.UTF-8/fr_FR.UTF-8/C/fr_FR.UTF-8/fr_FR.UTF-8

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] instaR_0.2.4 jsonlite_1.1 httr_1.2.1

loaded via a namespace (and not attached): [1] R6_2.2.0 curl_2.2 Rcpp_0.12.8 httpuv_1.3.3

chcariou commented 7 years ago

I had made a space error in my client key, sorry !