GitLab API: OAuth2 returns 401

GitLab API: OAuth2 returns 401

I have a question about the GitLab OAuth2 API. We want to use the GitLab API as a possible way to sign in since we already offer GitHub. I however hit a problem when asking for a access key. It will always return the same indescriptive error.

URL we post to:

What we are POSTING with a POST request client_id=THE_CLIENT_ID_HERE&client_secret=OUR_CLIENT_SECRET_HERE&code=CODE_WE_GOT_FROM_THEM_HERE&grant_type=authorization_code&redirect_uri=URL_ENCODED_LINK_HERE

We use our App ID in the client_id parameter. Our App secret is used in the client_secret parameter, the code we got from our authorization request is sent in the code parameter and We’ve URL encoded our Redirect URI, Which is the same as the one used in the Authorization request which performs fine.

However, what we do doesn’t matter. It does always return the following error. The request is missing a required parameter, includes an unsupported parameter value, or is otherwise malformed. . I’ve tried adding the earlier used state to no effect. We pass all the variables as stated in the Documentation and I can guarantee that the client_id, client_secret and code we pass with them are correct and newly received.

Are we missing something that’s not documented correctly? Or are we doing something wrong here? The Documentation we used can be found here: