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..
OAuth 2.0 (3LO) apps (atlassian.com)
I am stuck at this step
2. Exchange authorization code for access token
curl --request POST \ --url '<a href="https://auth.atlassian.com/oauth/token" rel="noopener nofollow noreferrer" target="_blank">https://auth.atlassian.com/oauth/token</a>' \ --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": "<a href="https://YOUR_APP_CALLBACK_URL" rel="noopener nofollow noreferrer" target="_blank">https://YOUR_APP_CALLBACK_URL</a>"}'
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
- HttpErrorResponse {headers: HttpHeaders, status: 400, statusText: 'OK', url: 'https://auth.atlassian.com/oauth/token', ok: false, …}
- error:
- error: "invalid_request"
- error_description: "authorization_code is invalid"
- [[Prototype]]: Object
- headers: HttpHeaders {normalizedNames: Map(0), lazyUpdate: null, lazyInit: ƒ}
- message: "Http failure response for https://auth.atlassian.com/oauth/token: 400 OK"
- 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