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

How to change token for github bridge? #995

Open
yarikoptic opened this issue Jan 16, 2023 · 20 comments
Open

How to change token for github bridge? #995

yarikoptic opened this issue Jan 16, 2023 · 20 comments

Comments

@yarikoptic
Copy link
Contributor

I had used git-bug over a year ago and have already configured bridge. Running it now results in

(git)smaug:/mnt/btrfs/datasets/datalad-git-bug[master]git
$> strace -f -o /tmp/bridge-pull.strace git bug bridge pull
import error: non-200 OK status code: 401 Unauthorized body: "{\"message\":\"Bad credentials\",\"documentation_url\":\"https://docs.github.com/graphql\"}"
imported 0 issues and 0 identities with default bridge

since I failed to find how to change the token, I found in that strace that auth was saved into /home/yoh/.config/git-bug/keyring/auth-0c111SENSORED which I moved aside in hope that git bug would ask me for a token to store -- but nope:

$> git bug bridge pull
A lock file is present but the corresponding process is not, removing it.
Error: missing identity token

So I decided to ask on how could I provide a new/replacement token?

$> git bug version 
git-bug version: 0.7.1-dev-b2e98ef07f
@guilbep
Copy link

guilbep commented Jan 23, 2023

@yarikoptic I'm using version v0.8.0 so I'm not sure if it's gonna help 0.7.1
but if you do a git bug bridge auth you'll have the list of token

➜  xxx git:(feat/xxx) git bug bridge auth
shaone github     token special_simple_token login:xxx

you can then do a git bug bridge auth rm shaone

and git bug bridge auth add-token --target github --login=yourlogin to add your newly generated token.

@MichaelMure I still think that finding 'documentation' insides the issues is a bad idea. It should be in the manpage at least imho
I can do a pull request if you change your mind.

Thank you for the great work

@MichaelMure
Copy link
Owner

Doc improvement is very very much welcome :-)

@yarikoptic
Copy link
Contributor Author

I'm using version v0.8.0 so I'm not sure if it's gonna help 0.7.1

indeed I had no output on my version. So I upgraded git-bug, tried it, was alerted to migrate, did migration

/home/yoh/proj/misc/git-bug-migration/git-bug-migration --for-real  297.43s user 148.24s system 89% cpu 8:18.22 total

but then got some odd error:

$> git-bug version
git-bug version: v0.8.0-dev-064d866ca5

$> git bug bridge auth
Building cache...
      bug 0 / -1 [-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------]  0 %
 identity 0 / -1 [-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------]  0 %
Error: cannot create new index, path already exists

$> echo $?
1

not clear which path it talks about, probably not related really to auth but rather something about git-bug since happens also for git-bug bug. search brought no hits. My guess - migration didn't go "well"?

@MichaelMure
Copy link
Owner

Not sure what's happening, but you can try to delete .git/git-bug to force recreating the cache. It looks like you have a conflicting file?

@yarikoptic
Copy link
Contributor Author

eh, moved all previous 144MB aside and rerunning... it was hanging for awhile on

Building cache...
      bug 2975 / 2975 [=================================================================================================>]  100 %
 identity   142 / 142 [=================================================================================================>]  100 %

after 20 minutes it was done but provided no remedy -- auth returns nothing, pull'ing with new git-bug results in the same error:

$> git-bug bridge auth

$> git bug bridge pull
Error: missing identity token

$> git bug version
git-bug version: v0.8.0-dev-064d866ca5

@MichaelMure
Copy link
Owner

Did you do what @guilbep suggested? #995 (comment)

@MichaelMure
Copy link
Owner

after 20 minutes it was done

We need to track why it's so slow.

@yarikoptic
Copy link
Contributor Author

Did you do what @guilbep suggested? #995 (comment)

may be I am missing specific aspect, but that is exactly what I was trying to do - to get the "identity" of the auth by running git-bug bridge auth but as I shown - it gives no output.

@yarikoptic
Copy link
Contributor Author

after 20 minutes it was done

We need to track why it's so slow.

may be a sheer number of issues (>2k) could be a reason? I remember that I had to run initial pull for an extended amount of time to get them all. .git/git-bug is now 221MB.

@MichaelMure
Copy link
Owner

Yes but you are rebuilding from local data. Did you notice it it stays long at 100%?

@yarikoptic
Copy link
Contributor Author

Yes but you are rebuilding from local data. Did you notice it it stays long at 100%?

yes, IIRC it was staying awhile after relatively quickly reaching 100%. I still have a tarball of not upgraded repository. I do not think it has any secrets in it. If you want, I can give it to you (100MB .tar.gz) to benchmark if so desired (may be my BTRFS file system got busy/slow at that point? unlikely though).

@MichaelMure
Copy link
Owner

@yarikoptic #1011 should get you a faster cache rebuild. I'd be curious to see how it perform for you.

@yarikoptic
Copy link
Contributor Author

now that it is updated, my "priority" is the original issue/question -- how to change the token?

@yarikoptic
Copy link
Contributor Author

ping -- any ideas on how to change the token?

@yarikoptic
Copy link
Contributor Author

probably nevermind, I worked around:

  • I established a bridge in another repo where git-bug also created a new token
  • I copy/pasted git-bug.identity entry between .git/config files and git bug bridge pull worked out

@smoyer64 smoyer64 reopened this Jan 31, 2023
@smoyer64
Copy link
Collaborator

Reopened because I think this is a valid user story - see #995 (comment) for a work-around.

@guilbep
Copy link

guilbep commented Feb 1, 2023

@smoyer64 @yarikoptic as I said above the following worked for me (in git-bug version 0.8.0) to update/change my token:

git bug bridge auth # to list the token
f1666cc github     token ghp_IWONTTELLYOU login:MYUSERNAME

git bug bridge auth rm f1666cc # to remove the token
git bug bridge auth add-token --target github --login= MYUSERNAME # to add your newly generated token.

By the way. Maybe the problem is from somewhere else. I noticed that only Tokens (classic) are working and not Fined grained tokens.
And that info is not in the documentation yet.

token_problem

@MichaelMure
Copy link
Owner

Nobody has cared to implement support for those new token. A good first step would be to know what changes need to happen: is it just a different validation regex? Do we need to do request differently?

@guilbep
Copy link

guilbep commented Feb 1, 2023

Nobody has cared to implement support for those new token. A good first step would be to know what changes need to happen: is it just a different validation regex? Do we need to do request differently?

I tried find the piece of code responsible for this. But I could not find It where should I look ? https://github.com/MichaelMure/git-bug/blob/master/bridge/core/auth/credential_test.go ?

@MichaelMure
Copy link
Owner

I believe everything is in https://github.com/MichaelMure/git-bug/blob/master/bridge/github/config.go.

Notably, you have the regex to validate a manually entered token: https://github.com/MichaelMure/git-bug/blob/master/bridge/github/config.go#L367

... and the process to generate a new token:

func requestToken() (string, error) {
scope, err := promptUserForProjectVisibility()
if err != nil {
return "", errors.WithStack(err)
}
resp, err := requestUserVerificationCode(scope)
if err != nil {
return "", err
}
promptUserToGoToBrowser(resp.uri, resp.userCode)
return pollGithubForAuthorization(resp.deviceCode, resp.interval)
}

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

No branches or pull requests

4 participants