Access Token: Error 400 Bad Request

Hi,

I’m trying to create a simple Python app as an OAuth 2.0 (3LO) application. I have been following the Jira guide OAuth 2.0 (3LO) apps

I set up a local server http://127.0.0.1:5000/callback and I’ve successfully obtained the authorization code. The next step is to Exchange authorization code for access token.

However, when I’m trying to do a POST request, I get an error 400: Bad Request. I’ve been trying to figure out what I did wrong but I can’t seem to find it. I am stuck at this point and unable to get the access token to proceed with the next step.

Any help is appreciated!

Here’s the code snippet for the POST request:

post_data = {'grant_type': 'authorization_code',
                         'client_id': testAppInst.client_id,
                         'client_secret': testAppInst.client_secret,
                         'code': parsed_code,
                         'redirect_uri': 'http://127.0.0.1:5000/callback'}

resp = requests.post(url='https://auth.atlassian.com/oauth/token',
                     headers={"Content-Type": 'application/json'},
                     data=post_data)

Issue is now fixed. The error was due to the dictionary not converted into a JSON. Converting it to JSON gave me the access code.