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

Github Gist with 2FA #9

Closed
JonasGroeger opened this issue Sep 2, 2016 · 7 comments
Closed

Github Gist with 2FA #9

JonasGroeger opened this issue Sep 2, 2016 · 7 comments

Comments

@JonasGroeger
Copy link
Contributor

JonasGroeger commented Sep 2, 2016

Hi!

I'm using GitHub with 2FA and in the file appveyor.yml I could not use this line:

- "ruby -e \"require 'gist'; Gist.login! username: ENV['github_user'], password: ENV['github_pass'] if ENV['github_user'] \""

If I do, the job at Appveyor just blocks (asking for a 2FA token).

Instead, I used my local machine, installed ruby, got the gist gem and logged running gist login. There I had to enter username and password. Another query comes up asking for a 2FA token. I enter it using my phone. A valid "Personal Access Token" (see https://github.com/settings/tokens) then is written into a file called ~/.gist.

In the appveyor.yml I added another line next to gist_id that says something like:

gist_token:
    secure: <YOUR_TOKEN_FROM_~/.gist>

Then, I replaced the - "ruby -e \"require ' ... line above with

  - ps: "$Env:gist_token | Out-File ~/.gist -Encoding ascii -NoNewline"

This should work for everybody with 2FA. I'm not sure how to submit this as a pull request since its kind of a special use case for people with 2FA "on" on Github. I'm also not sure how to put this into the appveyor.yml file since I'm not too experienced with Appveyor.

@ferventcoder
Copy link
Contributor

ferventcoder commented Sep 2, 2016

Interesting. In most cases (other tools) I was able to use my 2FA token as the password.

Here I haven't officially tested this as I was setting it up with @choco-bot

@JonasGroeger
Copy link
Contributor Author

JonasGroeger commented Sep 2, 2016

You can do that. However, I would rather want to keep my TOTP token private (like, really private) and use a token I can revoke: "Personal Access Token".

@ferventcoder
Copy link
Contributor

Personal access token is what I meant - man I got to work on my terminology! :)

@AdmiringWorm
Copy link
Member

I remember I could never get the ruby gist to work with a Personal Access Token,
so I ended up creating the minimal of powershell required to push the gist
to github instead.

https://github.com/AdmiringWorm/chocolatey-packages/blob/fa7877e83f301c34c7383acb64395861c0d4a97c/au/scripts/Save-Gist.ps1#L82

It is still quite the naïve implementation,
but could perhaps be an alternative than writing the token to file and
continue using the ruby gist application

@ferventcoder
Copy link
Contributor

Looks like @majkinetor has solved some of this for us with AU next.

@majkinetor
Copy link
Contributor

Yeah, this is the plugin: https://github.com/majkinetor/au/blob/integrate/AU/Plugins/Gist.ps1. The token is the only way to use it and arbitrary files can be uploaded.

@TheCakeIsNaOH
Copy link
Member

The gist plugin was added to update_all.ps1 in 6738ecb

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

5 participants