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 calling [github] without auth #9427

Merged
merged 3 commits into from
Aug 7, 2023
Merged

allow calling [github] without auth #9427

merged 3 commits into from
Aug 7, 2023

Conversation

chris48s
Copy link
Member

@chris48s chris48s commented Jul 31, 2023

Closes #2754
Refs #9386 (comment)

This PR resolves a long-standing issue that even though GitHub allows anonymous access to the v3 API with a reasonable rate limit, you have to set a key locally to do any development on any GitHub badges. The changes in #9386 make it extra desirable to be able to call the GH API without auth if possible.

I've set this PR to run the github test suite. Five of them will fail, but I submitted another PR to fix the tests at #9425 so we could merge that first then rebase this onto it, although I think the integration tests are actually the critical ones here.

@chris48s chris48s added the service-badge Accepted and actionable changes, features, and bugs label Jul 31, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Jul 31, 2023

Warnings
⚠️ This PR modified service code for github but not its test code.
That's okay so long as it's refactoring existing code.
Messages
📖 ✨ Thanks for your contribution to Shields, @chris48s!

Generated by 🚫 dangerJS against 871904a

...{
url,
query,
httpErrorMessages: { 401: 'auth required for graphql api' },
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The v4/GraphQL API doesn't allow anonymous access - a token is required

@@ -49,7 +49,11 @@ export default class GithubSearch extends GithubAuthV3Service {
},
},
schema,
httpErrors: httpErrorsFor('repo not found'),
httpErrors: {
401: 'auth required for search api',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The search API doesn't allow anonymous access - a token is required

'/repos/rust-lang/rust',
{},
)
expect(res.statusCode).to.equal(200)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I was working on this, I realised this test never actually asserted the calls were successful! 😬

@chris48s chris48s changed the title WIP allow calling [github] without auth allow calling [github] without auth Jul 31, 2023
@chris48s chris48s marked this pull request as ready for review July 31, 2023 11:03
Copy link
Member

@PyvesB PyvesB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good to me 👍🏻

@chris48s chris48s enabled auto-merge August 7, 2023 14:49
@chris48s chris48s added this pull request to the merge queue Aug 7, 2023
Merged via the queue into master with commit c586960 Aug 7, 2023
33 checks passed
@chris48s chris48s deleted the 2754-github-auth branch August 7, 2023 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
service-badge Accepted and actionable changes, features, and bugs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

All GitHub badges throw error with no token set
2 participants