Connect with REST API through Oauth2.0

Matteo De Franceschi May 6, 2021

Hello everybody. I tried to connect to my jira cloud instance with basic authentication but it throws me "deprecation" error. I've generated the code api with Swagger.

Is it possible to use the same code api but with Oauth authentication?

2 answers

1 accepted

1 vote
Answer accepted
Ismael Jimoh
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.
May 6, 2021

Hi @Matteo De Franceschi 

To connect your cloud instance using basic auth, you need to:

  1. Generate a token as explained here
  2. Next parse your username and the token as password to authenticate to your instance.

For Oauth, I believe this is also possible, however, I need to look this up.

Regards

Ismael Jimoh
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.
May 6, 2021

You can have a look at the following for Oauth authentication with Cloud.

Regards.

Matteo De Franceschi May 6, 2021

Ah ok, just tried and the authentication is working now.

Just another thing. When i try to achieve a Project it throws me this error:

Exception in thread "main" java.lang.IllegalArgumentException: missing discriminator field: <>
at com.atlassian.oauth.client.example.config.JSON.getDiscriminatorValue(JSON.java:2247)
at com.atlassian.oauth.client.example.config.JSON.access$000(JSON.java:37)
at com.atlassian.oauth.client.example.config.JSON$18.getClassForElement(JSON.java:1988)

 

Do you now something about?

David Smith January 14, 2022

Any updates on this, would be great if anyone could help in how to tackle this?

Emil Emilsson October 4, 2022

I got this to work, that is I have a test project which I can read the content of the issue with the correct oauth2 token and this path : 

first you go here : https://developer.atlassian.com/console/myapps/

create a app. Add all the scopes you need for access and take note of the client secret parts it generates

then you can go here : https://auth.atlassian.com/oauth/token
with grant type client_credentials

client_id and client_secret from that previous page

scope = your list of scopes you want

and if thats correctly done you get a access_token

 

then you call this : https://api.atlassian.com/oauth/token/accessible-resources 

 

and from there you get id: url etc. use that id as couldid here in the last thing below

https://api.atlassian.com/ex/jira/<cloudid>/rest/api/3/issue/<projectname>-<issue number>

 

and from that you can get issue details from jira.

 

hope that helps.

 

Regards,

Emil

0 votes
Vahe Vardanyan December 23, 2022

Hi,  when call this : https://api.atlassian.com/oauth/token/accessible-resources 

return all jira site, but i want to get only the datanet of the one i selected from sending code․ what can I do?

Vishal Bhojraj Khandate May 22, 2023

Hi, @Vahe Vardanyan did you find any answer to this? I am also stuck on the same problem.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD Trial
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events