I generated API token and refresh token using OAuth2.
The API token is used to make the following request by constructed link:
[POST] https://<OUR_DOMAIN>.atlassian.net/jira/deployments/0.1/cloud/<OUR_CLOUD_ID>/bulk
Cloud_id is returned from https://<OUR_DOMAIN>/_edge/tenant_info
An access token is generated via https://api.atlassian.com/oauth/token and submitted as an authorization bearer header.
I've tried to submit deployment data using postman and REST. The request sent data for a while but suddenly stopped working after regenerating the access token.
Now I get 401 Unauthorized when I call API.
Also, When I make a request by https://api.atlassian.com/oauth/token/accessible-resources I receive an empty list instead of the sites that have scopes granted by the token.
What may be the cause of this?
Hello @Julia Krivonos ,
I did a quick test start to finish following the OAuth2 doc you linked and Generating the token following the steps:
curl --request POST \ --url 'https://api.atlassian.com/oauth/token' \ --header 'Content-Type: application/json' \ --data '{ "audience": "api.atlassian.com", "grant_type":"client_credentials", "client_id": "<client_id_here>", "client_secret": "<client_secret_here>" }'
Returns the Access_Token used in the follow-up command under the "--header 'Authorization: Bearer " section:
curl --request POST \ --url 'https://api.atlassian.com/jira/builds/0.1/cloud/<CLOUD_ID_HERE>/bulk' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer <ACCESS_TOKEN_HERE>' \ --data '{Data section truncated for space}'
And got the results back as well as a build entry entered into my site as expected:
{"unknownIssueKeys":[],"acceptedBuilds":[{"pipelineId":"test-plan","buildNumber":5}],"rejectedBuilds":[]}
So it looks like the process in the doc is functioning correctly but something else is the blocker in your case.
From your description it seems to be indicating that it works but then you start getting 401s trying to generate new tokens, wondering if maybe the OAuth credentials got revoked or flag as expired somewhere in the process. Possibly on a permissions update as covered in:
Update OAuth credentials permissions
You can update your OAuth credentials permissions by adding or removing permissions for a tool. Adding a new permission will give the tool access to start sending in the type of data granted by the permission (e.g. deployment information). Removing a permission will revoke the tool’s access to send in the type of data that was granted by the permission.
I would recommend starting fresh by removing the OAuth credentials and rebuilding the connection.
Let me know how it goes.
Regards,
Earl
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.