git-bug icon indicating copy to clipboard operation
git-bug copied to clipboard

How to change token for github bridge?

Open yarikoptic opened this issue 3 years ago • 22 comments

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

yarikoptic avatar Jan 16 '23 23:01 yarikoptic

@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

guilbep avatar Jan 23 '23 09:01 guilbep

Doc improvement is very very much welcome :-)

MichaelMure avatar Jan 23 '23 10:01 MichaelMure

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"?

yarikoptic avatar Jan 23 '23 14:01 yarikoptic

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?

MichaelMure avatar Jan 23 '23 14:01 MichaelMure

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

yarikoptic avatar Jan 23 '23 18:01 yarikoptic

Did you do what @guilbep suggested? https://github.com/MichaelMure/git-bug/issues/995#issuecomment-1400072210

MichaelMure avatar Jan 23 '23 18:01 MichaelMure

after 20 minutes it was done

We need to track why it's so slow.

MichaelMure avatar Jan 23 '23 18:01 MichaelMure

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 avatar Jan 23 '23 18:01 yarikoptic

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.

yarikoptic avatar Jan 23 '23 18:01 yarikoptic

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

MichaelMure avatar Jan 23 '23 18:01 MichaelMure

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).

yarikoptic avatar Jan 23 '23 19:01 yarikoptic

@yarikoptic https://github.com/MichaelMure/git-bug/pull/1011 should get you a faster cache rebuild. I'd be curious to see how it perform for you.

MichaelMure avatar Jan 24 '23 12:01 MichaelMure

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

yarikoptic avatar Jan 24 '23 15:01 yarikoptic

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

yarikoptic avatar Jan 31 '23 20:01 yarikoptic

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

yarikoptic avatar Jan 31 '23 21:01 yarikoptic

Reopened because I think this is a valid user story - see https://github.com/MichaelMure/git-bug/issues/995#issuecomment-1411113570 for a work-around.

smoyer64 avatar Jan 31 '23 22:01 smoyer64

@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

guilbep avatar Feb 01 '23 08:02 guilbep

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?

MichaelMure avatar Feb 01 '23 08:02 MichaelMure

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 ?

guilbep avatar Feb 01 '23 09:02 guilbep

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: https://github.com/MichaelMure/git-bug/blob/1ae31b342b57ace44131f5ecd03c506814a25e62/bridge/github/config.go#L183-L194

MichaelMure avatar Feb 01 '23 10:02 MichaelMure

This bot triages untriaged issues and PRs according to the following rules:

  • After 90 days of inactivity, the lifecycle/stale label is applied
  • After 30 days of inactivity since lifecycle/stale was applied, the issue is closed

To remove the stale status, you can:

  • Remove the lifecycle/stale label
  • Comment on this issue

github-actions[bot] avatar Jul 23 '24 03:07 github-actions[bot]