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

Feat: Basic Authentication for Github API #68

Closed
jSadoski opened this issue Jul 30, 2020 · 2 comments · Fixed by #75
Closed

Feat: Basic Authentication for Github API #68

jSadoski opened this issue Jul 30, 2020 · 2 comments · Fixed by #75
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers to try

Comments

@jSadoski
Copy link
Contributor

Description

At this time, we're having issues hitting rate limits - especially when testing. GitHub only allows 10 requests/minute. Basic Authentication would allow up to 30/minute.

Why is it necessary? (or how would it make it better)

This is necessary to expand our ability to perform automated tests without those tests failing due to Rate Limit issues.

how do you think should it be implemented? (If possible)

I think we should use a username/api key in the request header for Basic Authentication. We could then just place the appropriate credentials in an environment variable and use click to access it. We could also cache the username/api key, which I presume we would want to do securely... Not sure how to do that without external modules or if our automated testing would support that.

I would love to work on this! I don't know much about the automated PR testing, however. I would need to know if we can run it with the env variable and which account credentials we would use for testing.

@jSadoski jSadoski added the enhancement New feature or request label Jul 30, 2020
@hedyhli
Copy link
Owner

hedyhli commented Jul 31, 2020

Thanks for putting up the issue, I had been thinking about prompting the user for API token if rate limit is hit and use it with request headers but didn't have the time. Using environment variables so it can be used in pytests is a great idea!

We could first implement the checking if rate limit is hit, and prompt the API token from the user, which can be generated from here (got the idea from githunt :D), and then use the token to be added in the header param like this (I know it's JavaScript but the header data is the same). Although using username/password instead of a token would also work, not sure which one would be better.

Details of implementation, just for inspiration
  • for prompting we could use rich.prompt for checking length/chars etc
  • it seems that status code 403 is returned when rate limit is hit
  • Storing the credentials in something like a data.json should be enough, because the user is only supposed to allow public repo access for the token, although we could also hash it for security


@jSadoski
Copy link
Contributor Author

jSadoski commented Aug 1, 2020

So I already got a personal token and I was able to use it with the addition of the requests-oauthlib package, so that works.

Maybe we should just start by making it an option like --auth username:token, then we could add the feature with rich to prompt once that's built in?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers to try
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants