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

Cannot use an access token when 2fa is active #458

Closed
claudio-walser opened this issue Jan 6, 2017 · 9 comments
Closed

Cannot use an access token when 2fa is active #458

claudio-walser opened this issue Jan 6, 2017 · 9 comments

Comments

@claudio-walser
Copy link

For some reason i cannot use an access token when 2fa on the given account is active.

  1. i can see the token is used when i disable 2fa on that account
    Jenkins GitHub Pull Request Builder — repo, repo:status -> Last used within the last day

  2. with 2fa enabled i can still do curl requests on the url ghprb uses for triggering build jobs
    curl -I -u my-user-name:my-access-token https://api.github.com/repos/my-org/my-repo/pulls?state=open

  3. But jenkins fails
    java.lang.Error: org.kohsuke.github.HttpException: Server returned HTTP response code: 401, message: 'Unauthorized' for URL: https://api.github.com/repos/my-org/my-repo/pulls?state=open

  4. I can run all checks in the configure page of ghprb with success with the given access token

    • Test basic connection to GitHub
      Connect to API
      Connected to https://api.github.com as null (null) login: my-user-name
    • Test Permissions to a Repository
      User has access to: Push, Pull
  5. As soon as i deactivate 2fa everything works just fine, which isn't an option at all

Can anyone tell me if i am doing anything wrong or if this is a bug?

Thanks

@benpatterson
Copy link
Member

Hmm it sounds like you're using an OAuth token? Ultimately this will be something in the underlying github-api. See issue here.

@claudio-walser
Copy link
Author

claudio-walser commented Jan 6, 2017

Hm, no basically i am using a normal access token...

@benpatterson
Copy link
Member

Gotcha. I would give this another go by creating an oauth token and using that as part of your credentials. I do think it's an issue that the ghprb plugin told you everything would be ok though, so I'm going to keep this issue open as a bug.

@claudio-walser
Copy link
Author

Good idea, will give the oath token a try on monday. Thanks for the hint ;)

@claudio-walser
Copy link
Author

By the way, i was adding the token using ghprb's button "create api token" in the configure section. Therefore i was not even thinking about creating a oauth token ;)

@claudio-walser
Copy link
Author

Didnt had success with oauth either and since i setup the token by using the configure page, the access token should be the desired way to use this plugin.

bildschirmfoto 2017-01-09 um 10 58 16

@bjoernhaeuser
Copy link
Contributor

I assume the underlying issue is now resolved and we can close this?

If not, please reopen.

@mutabletao
Copy link

Is there a link or help somewhere on exactly how to configure jenkins with 2fa in github? I've seen 3 different how-to sets of instructions and so far none of them work.. most just say "try turning off 2fa or using a different repo" none of which is a viable option.

Instructions like this (https://blog.tentamen.eu/jenkins-and-github-integration-using-webhooks/) which say they will solve the issue do not.. there is no successful code pull for any reason. authentication fails.

Using Oauth, with a private key and a webhook all at the same time still constantly fails. Any set of instructions that works with original jenkins (not blue ocean) would be great. Please not a link to another blog post saying it can be done or should work, but does someone have actual step by step that actually works?

@rwvandenberg
Copy link

@mutabletao @nikolaycnpopov - I churned on the same issue for a while.
This got me across the finish line:

CloudBees: GitHub Permissions and API token Scopes for Jenkins

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

No branches or pull requests

5 participants