githubgithub-apigithub-appgithub-oauth

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


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"}

Solution

  • Double check the url request parameters

    Validate your tokens

    Check for rate limits