Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to get auth 2.0

pedro_saavedra November 17, 2024

 

How can I obtain OAuth 2.0 authentication for Jira in order to use the following endpoint?

curl --request PUT \ --url 'https://api.atlassian.com/jsm/csm/cloudid/{cloudId}/api/v1/customer/{customerId}/details?fieldName=Region' \ --header 'Authorization: Bearer ' \ --header 'Accept: application/json' \ --header 'Content-Type: application/json' \ --data '{ "values": [ "EU" ] }'

I need detailed steps to generate the to authenticate this request.

1 answer

0 votes
Salih Tuç
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 17, 2024

Hi @pedro_saavedra welcome to the Community!


If you just want to use this API, you can use basic authentication with the username and API token.

If you want to integrate a custom app with JSM by using this endpoint, then you can check detailed steps from OAuth 2.0 (3LO) apps documentation.

Basically, the logic is as following:

1- Get the authorization code:

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

2 - Exchange the authorization code (from output of step 1) with the 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"}'

3 - Make request with the access token (from output of step 2)

curl --request GET \
--url <request URL> \
--header 'Authorization: Bearer ACCESS_TOKEN' \
--header 'Accept: application/json'

 

pedro_saavedra November 19, 2024

 

To use Basic Auth, the cloudId must belong to the same user as the Basic Auth. This has not worked for me with any APIs requiring cloudId, but it does work with those that do not require it.

Salih Tuç
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 19, 2024

Yeah, if you are trying to use ones with cloudId, as explained in this document, you need to use the OAuth 2.0, the steps are in the message above. Do you have a chance to try it?

If it worked, please don't forget to accept the answer.

pedro_saavedra November 19, 2024

 

I have not been able to create the oauth 2.0, I have doubts, which url goes in the callback, and the state=YOUR_USER_BOUND_VALUE, I don't know what it means either.

 

 

Salih Tuç
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 19, 2024

Then, you can continue with this documentation of OAuth.

Suggest an answer

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

Atlassian Community Events