Unable to get the access token getting 400 for OAUTH2.0 app

Rohit Magar
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 22, 2023

I have created a OAuth 2.0 app and I want this app to get the users project and ticket details.. but after I am done with the authorization url.. I am unable to get the access token..   

 

I am referring this doc 

OAuth 2.0 (3LO) apps (atlassian.com)

 I am stuck at this step

2. Exchange authorization code for access token

 

curl --request POST \ --url 'https://auth.atlassian.com/oauth/token' \ --header 'Content-Type: application/Json' \ --data '{"grant_type": "authorization_code","client_id": "YOUR_CLIENT_ID","client_secret": "YOUR_CLIENT_SECRET","code": "YOUR_AUTHORIZATION_CODE","redirect_uri": "https://YOUR_APP_CALLBACK_URL"}'
 

everything is they have asked.. i have added my client id and client secret.. but the Api is giving me 400

i get this as the response 

error
  1. HttpErrorResponse {headers: HttpHeaders, status: 400, statusText: 'OK', url: 'https://auth.atlassian.com/oauth/token', ok: false, …}
    1. error:
      1. error: "invalid_request"
      2. error_description: "authorization_code is invalid"
      3. [[Prototype]]: Object
    2. headers: HttpHeaders {normalizedNames: Map(0), lazyUpdate: null, lazyInit: ƒ}
    3. message: "Http failure response for https://auth.atlassian.com/oauth/token: 400 OK"
    4. name: "HttpErrorResponse"

I did some research and some said that content-type needs to be changed.. i updated the content type to 

contentType:"application/x-www-form-urlencoded; charset=utf-8"
than i get an error that client_id cannot be empty whereas in the payload of the network tab we can still see the client id


Also they have given a point like To get a refresh token in your initial authorization flow, add offline_access to the scope parameter of the authorization URL. Once you have the refresh token, exchange it for an access token by calling the token URL

I tried this and still I didn't get any refresh token 

is that I should take another approach or what is it.. please help me out.. we have deadline for this feature to develop

2 answers

0 votes
Cheyenne Carvalho
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 24, 2024

I have that same issue, Could you solve this? I would appreciate if you could share here. thank you

0 votes
Peter Van de Voorde
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 25, 2023

Hi @Rohit Magar ,


Welcome to the Atlassian Community.
This is very much an Atlassian Developer question and I would highly recommend for you to join the Atlassian Developer Community here: https://community.developer.atlassian.com

This community is solely focused on helping developers build apps on top of the Atlassian products and thus has a greater number of people who might be able to help you compared to the user community.

Cheers,
Peter

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
TAGS
AUG Leaders

Atlassian Community Events