401 with no error message on creating oauth token

I followed guide for retrieving access token from atlassian , but i have encountered 401 error when making request to https://auth.atlassian.com/oauth/token url, but i got this error
“General rest request error, cause:[401 Unauthorized: [no body]]”

Is there any way to get more info about error, cause i don`t know what can cause this error

Unfortunately, no. And I have had that same problem so many times, which lead me to curse OAuth for being so hard to observe & debug.

That said, we can rule out quite a few errors from the 401 status alone, and focus on the authentication part of the request. From the wrapper in the error message, it looks like you are trying to use a library. Can you provide some of the code context to inform which token flow is used and which tokens & secrets are involved (obviously obscure actual tokens & secrets, if not already in variables)?

Thanks for fast reply i use just RestTemplate with some custom logging , but overall there is no differences in how i make that request from that one in a guide
This is an object that i sent as a request body , all the variables are valid values

AccessTokenRequest accessTokenRequest = AccessTokenRequest.builder()
                .client_id(clientId)
                .client_secret(clientSecret)
                .grant_type("authorization_code")
                .code(authorizationCode)
                .redirect_uri(redirectUri)
                .build();

But strange thing happen if i change callback url in Oauth app so it will go to another application , it works just fine

@AdriianSemotiuk,

The OAuth docs explain:

  • redirect_uri: (required) Set this to the callback URL configured for your app in the developer console.

To elaborate, the redirect_uri must be the same in all 3 locations where it is used:

  • developer console
  • authorization URL (to obtain the authorization code)
  • token URL (to exchange the authorization code for an access token)

The last one will throw a 401 if the redirect_uri does not match the developer console.

Does that explain the behavior you are seeing?