Bridge wizard fails on gitlab token

Timeline

vtexier (vtexier) opened

I was stuck on git-bug bridge wizard, failing to connect with the Gitlab personal access token:

git-bug bridge configure
[1]: github
[2]: gitlab
[3]: jira
[4]: launchpad-preview
target: 2
name [default]: 
Gitlab server URL [https://gitlab.com/]: 
Gitlab project URL: https://gitlab.com/myproject
Gitlab login: mylogin
You can generate a new token by visiting https:/gitlab.com/profile/personal_access_tokens.
Choose 'Create personal access token' and set the necessary access scope for your repository.

'api' access scope: to be able to make api calls

Enter token: glpat-xxxxx
token has incorrect format
Enter token: xxxxx
token is invalid: GET https://gitlab.com/api/v4/user: 401 {message: 401 Unauthorized}

The string given is not accepted (it should). If I truncate the prefix, it fails.

Then I tried the command line with the full token with success:

 git-bug bridge configure --name=default --target=gitlab --url=https://gitlab.com/myproject --login=mylogin --token=glpat-xxxxx
Gitlab server URL [https://gitlab.com/]: 
Current identity dc710e2 tagged with login mylogin
Successfully configured bridge: default

Matěj Cepl (mcepl) commented (edited)

Also, the URL of new token is https://gitlab.com/-/profile/personal_access_tokens.

m2crypto@stitny (master)$ git bug bridge auth add-token --target=gitlab --login=mcepl
Building identity cache... Done.
Building bug cache... Done.
Enter the token:
glpat-somethingsecret
token something added
m2crypto@stitny (master)$ git bug bridge auth
Error: unknown credential type ""
m2crypto@stitny (master)$

Moritz Hedtke (mohe2015) commented

For me using the latest version in master and using "interactive token creation" worked.

Matěj Cepl (mcepl) commented

For me using the latest version in master and using "interactive token creation" worked.

For me it doesn’t:

vis-fzf-open@stitny (master)$ git remote -v
github	https://github.com/mcepl/vis-fzf-open.git (fetch)
github	git@github.com:mcepl/vis-fzf-open.git (push)
sourcehut	https://git.sr.ht/~mcepl/vis-fzf-open (fetch)
sourcehut	git@git.sr.ht:~mcepl/vis-fzf-open (push)
vis-fzf-open@stitny (master)$ rm -rf ~/.config/dotfiles/.git/modules/vis/plugins/vis-fzf-open/git-bug/
vis-fzf-open@stitny (master)$ git bug user create
Name [Matěj Cepl]:
Email [mcepl@cepl.eu]:
Avatar URL: https://avatars.githubusercontent.com/u/198999?s=400&v=4

de2aa1ef8534eec8d6cbed6d0932c760a8830842
vis-fzf-open@stitny (master)$ git bug bridge auth add-token --target=github -l mcepl
Enter the token:
ghp_something
token somethingelse added
vis-fzf-open@stitny (master)$ git bug bridge auth show
Error: accepts 1 arg(s), received 0
vis-fzf-open@stitny (master)$ git bug bridge configure
[1]: github
[2]: gitlab
[3]: jira
[4]: launchpad-preview
target: 1
name [default]:

Detected projects:
[1]: github.com/mcepl/vis-fzf-open

[0]: Another project

Select option: 1
Github login: mcepl
Error: unknown credential type ""
vis-fzf-open@stitny (master)$

Moritz Hedtke (mohe2015) commented

@mcepl I only used the bridge configure without adding a token before and there was a interactive auth option there.

Timothée Mazzucotelli (pawamoy) commented (edited)

Same thing for me, version 0.7.2. Full token gives "incorrect format", removing its prefix gives a 401. git-bug happily configured things when I passed the token non-interactively, using the command line --token option.

Michael Muré (MichaelMure) commented

Indeed. Sorry about that, I'm working my way there but i'm pretty busy on other life things.

Michael Muré (MichaelMure) closed the bug

Timothée Mazzucotelli (pawamoy) commented

No problem of course 🙂 Thank you for your work on git-bug. I don't often check it out, but it's there in a corner of my mind and today I wanted to try it again 😄 I'll keep an eye on the releases 😉