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

Allow for Github API authentication #18

Open
tyler-8 opened this issue Jul 22, 2019 · 6 comments
Open

Allow for Github API authentication #18

tyler-8 opened this issue Jul 22, 2019 · 6 comments
Assignees
Milestone

Comments

@tyler-8
Copy link

tyler-8 commented Jul 22, 2019

I recieved this error today while trying to pull down a gitignore file:

403: {"message":"API rate limit exceeded for <MY-IP>. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)","documentation_url":"https://developer.github.com/v3/#rate-limiting"}

So in environments where a lot of users might be behind one IP address (corporate proxy as an example) the unauthenticated API limits can be hit somewhat regularly. Perhaps using the locally configured git credentials would a good way around this.

@jamesharris-garmin
Copy link

do we have any intention to support this capability?

@CodeZombieCH
Copy link
Owner

CodeZombieCH commented May 12, 2021

Thanks for reporting this issue and sorry for the late reply.

Potential Solutions

I came up with the following solutions:

Authenticated Requests

Use unauthenticated requests until we hit the rate limit.
If the rate limit is reached, offer the user to authorize using the OAuth device flow
Store auth token using either:

Pros

  • Transparent for user and Github API

Cons

  • This is expected to dramatically increase the time it takes for a user to successfully choose and download a gitignore template due to extra steps required to aquire an OAuth acces token:
    1. request device and user verification code
    2. ask the user to open https://github.com/login/device and enter the code
    3. poll for the user authentication status
  • Token lifecycle management

gitignore Template Web Service

Create a simple web service that

Pros

  • No changes from a user perspective
  • No additional time required

Cons

  • Work to implement this service
  • Additional costs to run the service

Conculsion

Both solutions could be implemented as gitignore providers. This would allow the user to choose the provider that best suits its setup using a provider selection dropdown in the extension settings.

Example:
image

@rlivings39 @tyler-8 @jimmyharris @jamesharris-garmin
I would very much appreciate your thoughts about this

@CodeZombieCH CodeZombieCH added this to the v0.8.0 milestone May 12, 2021
@CodeZombieCH CodeZombieCH added this to Backlog in vscode-gitignore May 12, 2021
@CodeZombieCH CodeZombieCH self-assigned this May 12, 2021
@CodeZombieCH
Copy link
Owner

With the new version v0.8.0 I introduced the GITHUB_AUTHORIZATION environment variable allowing you to specify the value for the Authorization HTTP header. Check the "Authenticated GitHub API Requests" section in the README.md

@dantman
Copy link

dantman commented Jul 11, 2022

I don't think closing every vscode window and relaunching from a terminal with a manually created token is a great solution to this issue. It seems like even more work for the user than the first suggestion about OAuth token storage.

VSCode already has a system for handling GitHub authorizations. Which is used by the "GitHub Pull Requests and Issues", GitLens, and other VSCode extensions. Which the user will often already be signed in to and if not only needs to be setup once (the env var needs to be re-done every time in the future you start a project and need a .gitignore). I think this should just be used if the user hits the unauthenticated limit.

@CodeZombieCH
Copy link
Owner

Thanks for you feedback @dantman. I fully agree with you that environment variables are rather inconvenient.

I took a look the the "new" authentication providers introduced in July 2020 with version 1.48 and decided to try this approach. I'm currently working on a prototype that uses the following strategy:

  • Use unauthenticated GitHub API requests
  • If the rate limit is reached, prompt the user if he wants to authenticate using the built in GitHub authentication provider.

Will keep you posted.

@jamesharris-garmin
Copy link

Was there any progress on using the authentication providers? (been a while)

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

No branches or pull requests

4 participants