I am trying to get authorization code by calling GET request but getting "Javascript is disabled".

Rahul Shekhawat July 25, 2021

I am trying to access JIRA Rest APIs for which I would need authorization token to access the APIs. I am using OAuth 2.0 for this. Refer this link : https://developer.atlassian.com/cloud/jira/platform/oauth-2-3lo-apps/ This is what I am trying to achieve. This is the endpoint https://auth.atlassian.com/authorize? audience=api.atlassian.com& client_id=YOUR_CLIENT_ID& scope=REQUESTED_SCOPE_ONE%20REQUESTED_SCOPE_TWO& redirect_uri=https://YOUR_APP_CALLBACK_URL& state=YOUR_USER_BOUND_VALUE& response_type=code& prompt=consent I am hitting but I am not getting error "Javascript is disabled" error.

2 answers

0 votes
Hana Kučerová
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 25, 2021

Hi @Rahul Shekhawat ,

welcome to the Atlassian Community!

Would you please provide us more info, what you are trying to achieve? To which endpoint are you sending requests? How exactly does your request look like? Do you have some script for it, or are you using some application for sending requests?

Thank you.

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 25, 2021

What, exactly, do you mean by "authorisation code"?  Where are you looking?

I ask because it's clear the page you're asking it of needs to be able to run javascript, it's not intended for you to do things with a non-interactive call.  My guess would be that it needs you to log in.

Rahul Shekhawat July 25, 2021

Hi @Nic Brough -Adaptavist- , I am trying to access JIRA Rest APIs for which I would need authorization token to access the APIs. I am using OAuth 2.0 for this. Refer this link : https://developer.atlassian.com/cloud/jira/platform/oauth-2-3lo-apps/ This is what I am trying to achieve. This is the endpoint https://auth.atlassian.com/authorize? audience=api.atlassian.com& client_id=YOUR_CLIENT_ID& scope=REQUESTED_SCOPE_ONE%20REQUESTED_SCOPE_TWO& redirect_uri=https://YOUR_APP_CALLBACK_URL& state=YOUR_USER_BOUND_VALUE& response_type=code& prompt=consent I am hitting but I am not getting error "Javascript is disabled" error.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 25, 2021

Ok, that still looks like you are trying to hit a page intended for a human to use in a browser, not something you hit with a get.  What happens when you follow the documentation?

Like Yann Herren likes this
Yann Herren July 27, 2021

Exactly. Basically you need to open the authorization code request uri in a browser. Perhaps you tried to make the request in Postman or a similar tool which results in this error. As soon as you open the endpoint in a browser you'll be prompted to sign in and allow the app access to your account. After that, you are going to receive a code with which you can request an access token with a post request.  

Please refer to these two sections in the documentation:

Direct the user to the authorization URL to get an authorization code 

Exchange authorization code for access token 

FAsmani September 22, 2021

Hello @Yann Herren

 

I am working on the same thing as @Rahul Shekhawat

I followed your suggestion. I open that endpoint in the browser and accept the app access in my account but I am confused that where I will get the authorization code. Will you please help me with this?

FAsmani September 22, 2021

Please help me with that

Yann Herren September 22, 2021

Hi @FAsmani 

Basically you need to open that endpoint in the users browser. The then user authenticates with its credentials and consents to the app you created in the developer portal. You also need to define a Callback URL in your registration. This is the URL the user gets redirected to after a successful login. The authorization code is provided as the query parameter 'code' in the redirect call. So your redirect URL might be https://yourwebsite.com/yoursubsite. The OAuth redirect from Atlassian might look like this then: https://yourwebsite.com/yoursubsite?code=your-authorization-code

The documentation states this as well: 

If successful, the user will be redirected to the app's callback URL, with an authorization code provided as a query parameter called code. This code can be exchanged for an access token, as described in step 2.

On your end you then have to use the value of the query parameter to fetch an OAuth token in order to make authorized api calls.

Please refer to the section Direct the user to the authorization URL to get an authorization code in the documentation for further information.

Hope this helps!

Suggest an answer

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

Atlassian Community Events