Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 2
Message 1 of 3

Request to login/oauth/access_token returns error

Solved! Go to Solution.

Hello! I tried virtually everything and it's not working.

I can successfully get code and state.

But, when I try to exchange them to access token

POST https://github.com/login/oauth/access_token

request fails with no error message and 406 status code.

 

likern@likern:~/Breaffy/old-telegram-bot$ curl -v -H "Accept: application/vnd.github.machine-man-preview+json" -X POST "https://github.com/login/oauth/access_token?client_id=Iv1.daa70164e608e4a0&client_secret=0a93af098d3d310ceee6b023b99ab1921b0b1076&code=25734a3fe561f0ea6752&state=1d257fb4-448a-4208-b785-76ff7b8f8346"
* Trying 140.82.118.4...
* TCP_NODELAY set
* Connected to github.com (140.82.118.4) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
* CAfile: /etc/ssl/certs/ca-certificates.crt
CApath: /etc/ssl/certs
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN, server accepted to use http/1.1
* Server certificate:
* subject: businessCategory=Private Organization; jurisdictionC=US; jurisdictionST=Delaware; serialNumber=5157550; C=US; ST=California; L=San Francisco; O=GitHub, Inc.; CN=github.com
* start date: May 8 00:00:00 2018 GMT
* expire date: Jun 3 12:00:00 2020 GMT
* subjectAltName: host "github.com" matched cert's "github.com"
* issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=DigiCert SHA2 Extended Validation Server CA
* SSL certificate verify ok.
> POST /login/oauth/access_token?client_id=Iv1.daa70164e608e4a0&client_secret=0a93af098d3d310ceee6b023b99ab1921b0b1076&code=25734a3fe561f0ea6752&state=1d257fb4-448a-4208-b785-76ff7b8f8346 HTTP/1.1
> Host: github.com
> User-Agent: curl/7.58.0
> Accept: application/vnd.github.machine-man-preview+json
> 
< HTTP/1.1 406 Not Acceptable
< Date: Wed, 24 Apr 2019 20:40:41 GMT
< Content-Type: text/html
< Transfer-Encoding: chunked
< Server: GitHub.com
< Status: 406 Not Acceptable
< Vary: X-PJAX
< Cache-Control: no-cache
< Set-Cookie: has_recent_activity=1; path=/; expires=Wed, 24 Apr 2019 21:40:41 -0000
< Set-Cookie: ignored_unsupported_browser_notice=false; path=/
< X-Request-Id: e39c1dfb-531d-4244-83c8-35398dac0197
< Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
< X-Frame-Options: deny
< X-Content-Type-Options: nosniff
< X-XSS-Protection: 1; mode=block
< Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin
< Expect-CT: max-age=2592000, report-uri="https://api.github.com/_private/browser/errors"
< Content-Security-Policy: default-src 'none'; base-uri 'self'; block-all-mixed-content; connect-src 'self' uploads.github.com www.githubstatus.com collector.githubapp.com api.github.com www.google-analytics.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com wss://live.github.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com; frame-ancestors 'none'; frame-src render.githubusercontent.com; img-src 'self' data: github.githubassets.com identicons.github.com collector.githubapp.com github-cloud.s3.amazonaws.com *.githubusercontent.com; manifest-src 'self'; media-src 'none'; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com
< X-GitHub-Request-Id: D112:46021:117A699:1A4BB95:5CC0C9C9
< 
* Connection #0 to host github.com left intact
2 Replies
Solution
Commander Lvl 2
Message 2 of 3

Re: Request to login/oauth/access_token returns error

Hi @likern,

 

Welcome to the Github Community Forum!

 

I search for some solution and i find this where explain the error code: developer.mozilla.org/Status/406.

It seems that you are not send the right list of acceptable values defined in the request's proactive content negotiation headers.

Did you follow this guide? -> developer.github.com/apps/building-oauth-apps/authorizing-oauth-apps/

 

-Gabriele-

 

Mark helpfull posts with Accept as Solution to help other users locate important info. Don't forget to give Kudos for great contents!

Highlighted
Copilot Lvl 2
Message 3 of 3

Re: Request to login/oauth/access_token returns error

Thank you so much! You really helped me ;)

I added Accept: 'application/json' and this starts working =)