title: instaR http error 400, can't get access token
body: <p>i've been trying to use instaR, but failed at getting an access token - getting the response:</p>
  
  <blockquote>
    <p>Authentication complete.</p>
    
    <p>Error in init_oauth2.0(self$endpoint, self$app, scope = self$params$scope, :</p>
    
    <p>Bad Request (HTTP 400). Failed to get an access token.</p>
  </blockquote>
  
  <p>when examining the request using with_verbose(), i don't see any additional info.</p>
  
  <pre><code>httr::with_verbose(my_oauth &lt;- instaOAuth(app_id=client_id,app_secret=client_secret))
  </code></pre>
  
  <p>this is the response i get (masked the client id and secret):</p>
  
  <blockquote>
    <p>Waiting for authentication in browser...
    Press Esc/Ctrl + C to abort</p>
    
    <p>Authentication complete.</p>
    
    <p>POST /oauth/access_token HTTP/1.1</p>
    
    <p>Host: api.instagram.com</p>
    
    <p>User-Agent: libcurl/7.43.0 r-curl/2.2 httr/1.2.1</p>
    
    <p>Accept-Encoding: gzip, deflate</p>
    
    <p>Cookie: csrftoken=oLgx7eQh8uZH1ZWMl53lC2y0JJWQkmwd</p>
    
    <p>Accept: application/json, text/xml, application/xml, /</p>
    
    <p>Content-Type: application/x-www-form-urlencoded</p>
    
    <p>Content-Length: 206</p>
    
    <p>client_id=[CLIENT_ID]&amp;redirect_uri=http%3A%2F%2Flocalhost%3A1410%2F%2F&amp;grant_type=authorization_code&amp;code=98e38f8c53354a22bd3786f96cd19e3e&amp;client_secret=[CLIENT_SECRET]</p>
    
    <p>&lt;- HTTP/1.1 400 Bad Request</p>
    
    <p>&lt;- Cache-Control: private, no-cache, no-store, must-revalidate</p>
    
    <p>&lt;- Vary: Cookie, Accept-Language</p>
    
    <p>&lt;- Content-Language: en</p>
    
    <p>&lt;- Date: Mon, 21 Nov 2016 00:27:48 GMT</p>
    
    <p>&lt;- Content-Type: application/json</p>
    
    <p>&lt;- Pragma: no-cache</p>
    
    <p>&lt;- Expires: Sat, 01 Jan 2000 00:00:00 GMT</p>
    
    <p>&lt;- Set-Cookie: csrftoken=oLgx7eQh8uZH1ZWMl53lC2y0JJWQkmwd; expires=Mon, 20-Nov->2017 00:27:48 GMT; Max-Age=31449600; Path=/; Secure</p>
    
    <p>&lt;- Connection: keep-alive</p>
    
    <p>&lt;- Content-Length: 114</p>
    
    <p>&lt;-</p>
    
    <p>Error in init_oauth2.0(self$endpoint, self$app, scope = self$params$scope, :</p>
    
    <p>Bad Request (HTTP 400). Failed to get an access token.</p>
  </blockquote>
  
  <p>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). i tried both the current version and 1.1.0 with the same results.</p>
  
  <blockquote>
    <p>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)</p>
    
    <p>locale:
    [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8</p>
    
    <p>attached base packages:
    [1] stats graphics grDevices utils datasets methods base</p>
    
    <p>other attached packages:
    [1] instaR_0.2.4 jsonlite_1.1 httr_1.2.1</p>
    
    <p>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</p>
  </blockquote>
  
  <p>found some interesting info at <a href="https://github.com/hadley/httr/issues/379" rel="nofollow noreferrer">https://github.com/hadley/httr/issues/379</a>, but no solution.</p>
  
  <p>any help would be greatly appreciated!</p>