simon
simon

Reputation: 3496

JIRA REST API call with oauth, where to put token?

after a successfull login via oauth I'm receiving a bunch of data.

"oauth_token" => "07HQgsnnXaaaaaaaaaaki0GA9wGj2ThO"
"oauth_token_secret" => "2853FBbR5WbbbbbbbbbbIdQIMp5kmXVw" 
"oauth_expires_in" => "157680000" 
"oauth_session_handle" => "2a2ccccccccccKRiQmrl7EsPQd7f0QD7" 
"oauth_authorization_expires_in" => "160272000"

I would like to make api-calls to the rest api. In the Authentication-chapter of the documentation (https://docs.atlassian.com/jira/REST/cloud/#auth/1/session-currentUser) it's listet that the oauth authentication is the prefered method.

In the liinked examples it's clear thet username:password authentication is way easier (https://developer.atlassian.com/jiradev/jira-apis/jira-rest-apis/jira-rest-api-tutorials). In fact in the whole documentation there are all examples with the easier username:password authentication( fred:fred). In my case I'm wondering how the token after a oauth-authentication is transfered in a request to the rest-api.

Do I have to add it to the header? With which name? Or do I have to append it to every url?

The only "valid" help in the documentation is this line, but here you cannot see how the access token is included into the request

java -jar rest-oauth-client-1.0.one-jar.jar request ACCESS_TOKEN JIRA_REST_URL

Has anyone solved this already? Where do I have to put the oauth_token?

Best Regards

Upvotes: 2

Views: 1974

Answers (3)

Ashadi Sedana Pratama
Ashadi Sedana Pratama

Reputation: 867

you need to create a token by following this instruction https://support.atlassian.com/atlassian-account/docs/manage-api-tokens-for-your-atlassian-account/

After the token is generated, you need to copy it. You can test it at Postman using Basic Auth with username as your email and password as the token. enter image description here

Upvotes: 0

Kesarion
Kesarion

Reputation: 2848

You put it in the authorization header for every request like so:

var headers = {
    Authorization: 'Bearer ' + oauthToken
};

The ehaders object will be a parameter for your http client request. Depending on the framework you're using you can probably add it as default header configuration so it's added automatically for every request and you don't have to worry about it.

Upvotes: 0

simon
simon

Reputation: 3496

I think I found the answer to the problem. The process is good desccribed at https://dev.twitter.com/oauth/overview/creating-signatures

Best regards

Upvotes: 0

Related Questions