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

Re-configure api token when using keyring #160

Closed
vanniktech opened this issue Apr 3, 2018 · 26 comments
Closed

Re-configure api token when using keyring #160

vanniktech opened this issue Apr 3, 2018 · 26 comments
Labels

Comments

@vanniktech
Copy link
Contributor

vanniktech commented Apr 3, 2018

I've ended up with a bad API token inside keyring that is no longer granted for usage.

How can I refresh the token and store a new one?

@coryb
Copy link
Contributor

coryb commented Apr 3, 2018

which keyring are you using? Are you using the system keyring on osx or using pass?

@vanniktech
Copy link
Contributor Author

Oh sorry. keyring on an Ubuntu machine. So that's probably gnome-keyring.

@coryb
Copy link
Contributor

coryb commented Apr 3, 2018

If you are using pass, then you can use:

pass rm --force GoJira/api-token:<user>

where <user> is the user: property in the .jira.d/config.yml file (defaults to $USER environment variable).

If you are using your system keystore then there should be a key named GoJira/... in there that you can browse to and remove.

I will probably modify the jira logout command to make this easier.

@vanniktech
Copy link
Contributor Author

Yeah I also tried jira logout but it said it's not necessary. Would be great to have an addition that would remove the key.

@vanniktech
Copy link
Contributor Author

I've tried seahorse which seems to be the thing for looking up the keyring passwords. However there's a default password for it and I don't know what it is. Bottom line is that I can't access any of them so I can't delete it either.

@coryb
Copy link
Contributor

coryb commented Apr 3, 2018

I have never actually used gnome-keyring, apparently deleting a key is not easy:
https://blmath.wordpress.com/2009/07/07/remove-password-from-keyring/ that will delete all your keys, which is dumb.

I am trying to add in a prompt now to the logout command.

@vanniktech
Copy link
Contributor Author

Yeah another solution I've read online is rm ~/.local/share/keyrings which is equally as bad. The prompt would be nice.

@coryb
Copy link
Contributor

coryb commented Apr 3, 2018

I have added the prompt, hopefully it will work for you. You will have to build go-jira locally from source:
https://github.com/Netflix-Skunkworks/go-jira#build

@vanniktech
Copy link
Contributor Author

go install ./ worked. Where can I find the executable? Sorry for the questions - never worked with Go before.

@coryb
Copy link
Contributor

coryb commented Apr 3, 2018

If you just want to install the binary:

go get -u gopkg.in/Netflix-Skunkworks/go-jira.v1/cmd/jira

That should install it to $GOPATH/bin which defaults to $HOME/go/bin

-Cory

@vanniktech
Copy link
Contributor Author

I don't get the prompt when running ./jira logout. Could it correlate to the failing master build?

@vanniktech
Copy link
Contributor Author

I know for a fact that I'm running a different version since I'm now seeing this issue #163

@coryb
Copy link
Contributor

coryb commented Apr 3, 2018

Not sure what going on. The tests failed on the build due to the prompt being added (test's dont expect that prompt) , but that wont effect your build. I built it locally and it worked for me.

@vanniktech
Copy link
Contributor Author

Could it be that globals.GetPass() is empty?

@coryb
Copy link
Contributor

coryb commented Apr 3, 2018

If that is the case then it implies your api-token has been flushed from the keychain and you should be good?

@vanniktech
Copy link
Contributor Author

I should be yes - but I'm not. I've also tried restarting, deleteting ~/go, redownloading. Nothing seems to get that prompt to show.

@coryb
Copy link
Contributor

coryb commented Apr 3, 2018

Lets take a step back, when you run something like jira list do you get prompted for an api-token or does it just fail (and if so with what error message).

@vanniktech
Copy link
Contributor Author

vanniktech commented Apr 3, 2018

When I use password-source: keyring I don't get prompted for an access token. In this case executing jira list yields a 401.

When I don't use password-source: keyring I get prompted for an access token. Once I enter the new valid one I see the issues.

@coryb
Copy link
Contributor

coryb commented Apr 3, 2018

Okay, I am pretty confused with what is going on. In theory when you get the 401 we are supposed to prompt you again for another token to use, but that code may have been lost in a refactor. I dont have time to really dig into this further, for now can you unset the password-source property and just set the JIRA_API_TOKEN environment variable?

@vanniktech
Copy link
Contributor Author

I'll try this tomorrow as I'm no longer at my work computer where I had this problem.

Which exact property are you talking about when you're referring to password-source?

@coryb
Copy link
Contributor

coryb commented Apr 3, 2018

You said you have password-source: keyring set, I just meant to unset that and try the JIRA_API_TOKEN environment variable for now.

@vanniktech
Copy link
Contributor Author

Oh yes, you're right. Got mixed up.

@vanniktech vanniktech reopened this Apr 4, 2018
@vanniktech
Copy link
Contributor Author

Whops. Using the environment variable works fabulously.

@coryb coryb added the bug label Apr 15, 2018
@coryb
Copy link
Contributor

coryb commented Apr 15, 2018

I can now reproduce the issue. It should ask for a new api-token when we get a 401, but for some reason it is just throwing an error while trying to parse the 401 response as json. I will try to get it resolved.

@coryb
Copy link
Contributor

coryb commented Apr 16, 2018

@coryb coryb closed this as completed Apr 16, 2018
@SijanC147
Copy link

SijanC147 commented Nov 4, 2022

Was this issue fixed? am still experiencing this. I entered the wrong API key by mistake the first time, and now if i include password-source: keyring it always fails. jira logout suggests that it's deleting something, but doesn't fix the issue the next time i run any command. Removing the keyring setting from config makes it ask for my token on every command. Am i missing something?

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

3 participants