Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

401 unauthorized error even though API token successful #248

Open
almostfamous09 opened this issue Apr 14, 2020 · 22 comments
Open

401 unauthorized error even though API token successful #248

almostfamous09 opened this issue Apr 14, 2020 · 22 comments
Labels

Comments

@almostfamous09
Copy link

** Provide a general summary of the issue in the Title above **

My colleagues are able to refresh an existing table but my refresh button does not do anything.
Tried to create a fresh table and received an 401 unauthorized error and am unable to create.

** Provide a more detailed information of the issue **

Steps to reproduce

** Provide Debugging information **
For further investigation, please activate Debugging in "About" dialog, provide us with your "Temp. User Key" and then perform at least one another try. This way it will log the error and debug information to project owners StackDriver logging account where we can analyze it better.

Note: User credentials are not transmitted in any log data.

Temp user key: AI3kGSge9aZxGoHCP/bjiBa/suZLxdUvo2CkqYsf0D9oZM7lX2HNRZDojFBkRDh/1SqnSEMI1mGc

Steps to reproduce

** Provide a set of unambiguous steps to reproduce this bug include code, if relevant **
1.Open Google Sheets > Add-Ons > Project Aid for JIRA > Settings
2. Used proper JIRA link, username and API token.
3. Creating a new issue table --> Receiving a 401 Unauthorized error on
Also not able to refresh an existing table my colleague set up
API token set up said successful and Jira API is active and refesh seems accurate

Expected result

** Tell us what should happen **

  1. refresh data table

Actual result

** Tell us what happens instead **

  1. Click refresh nothing happens
  2. Create new issue table --> 401 error

Screen Shot 2020-04-14 at 2 37 44 PM

@ljay79
Copy link
Owner

ljay79 commented Apr 15, 2020

Hi @almostfamous09
as the screenshot indicates, apparently your account / user is not allowed to retrieve the filters from your Jira instance.
I would suggest to get in touch with your admin to check your users permissions.

BTW: The Logs indicating same on my end:

https://vydia.atlassian.net/rest/api/2/filter/my?includeFavourites=true

The selected filter is not available to you, perhaps it has been deleted or had its permissions changed.

@almostfamous09
Copy link
Author

Hi @ljay79 - This is what I assume as well, however I am the admin and my permissions are exactly the same as the PM that set up this filter. It works for the other PMs on the team. Filter permissions seem to be at the project level and we only have one project so this should work. I can see the filter but I cannot refresh the connected table / sheet.

@ljay79
Copy link
Owner

ljay79 commented Apr 20, 2020

In Jira itself, can you see and access the filter in question.

@almostfamous09
Copy link
Author

Yes I can see it and have it starred
Screen Shot 2020-04-21 at 10 48 35 AM

@ljay79
Copy link
Owner

ljay79 commented Apr 21, 2020

Strange. Can you create a complete new spreadsheet and try insert a new IssueTable. Maybe even try a new very basic filter.

Just to eliminate a few possibilities of root cause.

@almostfamous09
Copy link
Author

I created a brand new sheet and selected to "Create Issue Table from Filter" and before I could even make a selection I get that red error bar "No filters available!Failed to retrieve jira filters with status [401]!\nUnauthorized" even though my token is connected successfully and refreshes in Jira.

In addition to the favorite filter colleague made, I created my own filter to see if that would resolve the issue. However, even as the creator/owner of a filter this error still occurs.

Any other ideas?

Thanks

@ljay79
Copy link
Owner

ljay79 commented Apr 22, 2020

What happens when you access (via menu) the "Configure Custom fields" and/or "Show Jira field map"?

@ljay79
Copy link
Owner

ljay79 commented Apr 22, 2020

BTW: Could you please provide me with your new Temp user key.

@almostfamous09
Copy link
Author

Temp Key: ALEt7zSqBsLalUhwlo/4/QLg/lqhqBcLy7NhkJo2BOY0wysoEpDuvDVnsy/eCAENQ7aBcn0KjrPX

Here's what configure custom fields looks like:

Screen Shot 2020-04-23 at 10 27 47 AM

@ljay79
Copy link
Owner

ljay79 commented Apr 23, 2020

Are you using email + token or username + token for your credentials?

@ljay79
Copy link
Owner

ljay79 commented Apr 23, 2020

Please try to perform following in a terminal/console window on your workstation:

Replace "emailAddress" and "apiToken" with your own values.

Jira server:

curl -u emailAddress:apiToken -X GET -H "Content-Type: application/json" https://vydia.atlassian.net/rest/api/2/filter/favourite

Jira cloud:

curl -u emailAddress:apiToken -X GET -H "Content-Type: application/json" https://vydia.atlassian.net/rest/api/2/filter/my

Let me know what the response is...

@ljay79
Copy link
Owner

ljay79 commented Jun 24, 2020

@almostfamous09 any new on this?
As it affects your filters and custom fields, i believe it is something related to permissions / authentication

@gewuerzgurke84
Copy link
Contributor

Hello together,

I've just checked the sourcecode and found the authentication always uses HTTP Basic Authentication

headers: {"Authorization": "Basic "},

If one would like to use personalized API tokens instead of original username/password from JIRA then Bearer Authentication seems to be required (see https://confluence.atlassian.com/enterprise/using-personal-access-tokens-1026032365.html)

We really found this Addon very useful but cannot provide user/pass due to security guidelines. Using an API token for that purpose would work for us. Any chance to implement:

  1. Selection on the configuration panel to select between user/pass vs user/token authentication
  2. Change authentication-type depending on user config

Thanks & Best Regards,
Alex

@gewuerzgurke84
Copy link
Contributor

Hi @ljay79 ,
any chance the mentioned improvement could be implemented? Let me know if you need further information.
Thx & BR,
Alex

@ljay79
Copy link
Owner

ljay79 commented Jan 25, 2021

Hi @gewuerzgurke84
sry for my late reply.
Actually the add-on does support personalized Token to be used instead of password and is actually recommending it.
Please check the readme: https://github.com/ljay79/jira-tools#b-atlassian-api-token

Did you tried that already?

@gewuerzgurke84
Copy link
Contributor

Hi @ljay79,

I think you're refering to the API-Tokens which are implemented on Jira Cloud. We run Jira instances on-premise (server/dc edition) which provide so called "Personal Access Token" in recent versions (see https://jira.atlassian.com/browse/JRASERVER-67869). These personal access tokens do not have username/password using Basic-Auth but use a bearer token:

curl -X GET -H "Authorization: Bearer $mySecureToken" https://myJiraHost/myRestCall

Thx & BR,
Alex

@ljay79
Copy link
Owner

ljay79 commented Jan 25, 2021

You are right, i understand now. "API Token" vs. "Personal Access Token".
The things is, it appears to me a quite trivial feature change, however i do not have any Jira Server to test anything with.

Would you be able to temporary setup a test user on your system so i might be able to integrate such feature and test it properly?

@gewuerzgurke84
Copy link
Contributor

Sure, we can do this. Maybe you could provide an email address/telegram/whatever you prefer, so I can drop you the link, username, password?

ljay79 added a commit that referenced this issue Jan 28, 2021
@ljay79
Copy link
Owner

ljay79 commented Jan 28, 2021

@gewuerzgurke84 please check it out. Release v1.4.9 is now published supporting "Personal Access Token" for Bearer authentication.

@gewuerzgurke84
Copy link
Contributor

Cool, thanks a lot for the release. I've justed tested it and it work's really good. One trivial issue I've found is that there is no error message if you try a wrong personal access token. Only in case the token is valid a success message shows up...

@ljay79
Copy link
Owner

ljay79 commented Jan 29, 2021

Yeah, i will need to see if this specific to your server or an general issue.
The API is responding with Status 200 and a fancy HTML page instead of authorization error or similar :(

curl -X GET -I \
	-H "Authorization: Bearer asasas" \
	-H "Accept: application/json" \
	-H "Content-Type: application/json" \
	https://myJiraHost/myRestCall

@emilyakavor
Copy link

Yeah, i will need to see if this specific to your server or an general issue. The API is responding with Status 200 and a fancy HTML page instead of authorization error or similar :(

curl -X GET -I \
	-H "Authorization: Bearer asasas" \
	-H "Accept: application/json" \
	-H "Content-Type: application/json" \
	https://myJiraHost/myRestCall

Getting the same behavior for confluence server REST API. Wrong token returns 200 with a proper json response looking like this {"results":[],"start":0,"limit":25,"size":0,"_links":{"self":"http://confluence.example.com/rest/api/space","base":"http://confluence.example.com","context":""}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants