Gitlab authorization server returns authorization code, but doesn't authorize my app

I try to get an access token following https://tools.ietf.org/html/rfc6749#section-4.2.1 and gitlab docs.

I redirect user to the following page:
https://gitlab.com/oauth/authorize?client_id=[MY CLIENT ID HERE]&redirect_uri=[MY REDIRECT URI HERE]&scope=read_repository&response_type=code

It successfully returns a code like:
c3cbd10a619758353ec0a5888eb30709e3877ae480ec3fa982c0e50f64459d44

But on the https://gitlab.com/-/profile/applications page I don’t see my app in the list of authorized apps.
Also if I am using the code I got on the authorization step, then I get an error:

{
  "error": "invalid_grant",
  "error_description": "The provided authorization grant is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client."
}

Seems GitLab returns the code, but doesn’t authorize my app in reality.

  • What are you seeing, and how does it differ from what you expect to see?
    I don’t see my app in the list of authorized apps on https://gitlab.com/-/profile/applications after authorization process, despite of successful redirect back to my app with an authorization code. Also I get the error on gitlab authorization page:
  • Consider including screenshots, error messages, and/or other helpful visuals
  • What version are you on (Hint: /help) ? and are you using self-managed or gitlab.com?
    I am using gitlab.com
  • What troubleshooting steps have you already taken? Can you link to any docs or other resources so we know where you have been?
    I’ve checked https://tools.ietf.org/html/rfc6749#section-4.2.1 to be sure all fields I provide are ok
    Thanks for taking the time to be thorough in your request, it really helps! :blush: