Encountering 404 Error 'Not Found' When Exchanging Code for Token using GitHub OAuth API

74 Views Asked by At

I'm encountering a problem while trying to exchange a code for a token using the GitHub OAuth API. Whenever I make a request to the URL https://github.com/login/oauth/access_token, I receive a 404 {"error":"Not Found"} error in response.

What I've Tried:

I've attempted to resolve this issue using various approaches, including:

  1. Making a cURL call.
  2. Utilizing the new Octokit() constructor with createOAuthUserAuth().

Relevant Information:

Octokit version: 3.1.2

Example of the cURL call:

$ curl -X POST \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -H "User-Agent: axios/0.21.1" \
  -H "Accept: application/json" \
  -d "client_id=XXXXXX" \
  -d "client_secret=XXXXXXX" \
  -d "grant_type=authorization_code" \
  -d "code=XXXXXX" \
  -d "redirect_uri=https://example.com" \
  https://github.com/login/oauth/access_token

{"error":"Not Found"}
2

There are 2 best solutions below

1
Ravin Bandara On BEST ANSWER

Double check the url request parameters

Validate your tokens

Check for rate limits

0
Ravin Bandara On

https://github.com/login/oauth/access_token your getting this error because your endpoint is failing or do not exist.

POST https://github.com/login/oauth/access_token use this correct end point to check if it's working

and verify HTTP methods.