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

Lessen required scopes #24

Closed
dpi opened this issue Apr 30, 2023 · 6 comments
Closed

Lessen required scopes #24

dpi opened this issue Apr 30, 2023 · 6 comments

Comments

@dpi
Copy link

dpi commented Apr 30, 2023

Calling \League\OAuth2\Client\Provider\AbstractProvider::getResourceOwner in certain circumstances throws an exception.

When only the 'read:user' scope is configured and the authenticating user does not have a public email, eventually \League\OAuth2\Client\Provider\Github::fetchResourceOwnerDetails is called. The initial response has a $response['email'] = null. This eventually leads to another request to the /emails endpoint. However this endpoint won't load due to the configured scopes.

The following exception is thrown while trying to fulfill the request:

\League\OAuth2\Client\Provider\Exception\GithubIdentityProviderException

Code: 404
Message: {"message":"Not Found","documentation_url":"https://docs.github.com/rest/reference/users#list-email-addresses-for-the-authenticated-user"}

It should be possible to match scopes required to load this endpoint before attempting. As far as I can tell the response doesn't necessarily require emails. Scopes needed: user or user:email per https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/scopes-for-oauth-apps#available-scopes + https://docs.github.com/en/rest/users/emails?apiVersion=2022-11-28#list-email-addresses-for-the-authenticated-user.

The relevant lines for resolving emails were modified in the last 6 months.

@dpi
Copy link
Author

dpi commented Apr 30, 2023

Looks like the relevant recently modified files from #20 #22 lead to this change, perhaps intentionally.

I should be able to use this project without emails?

My desire is to claim that my integration does not collect emails, such that I don't need to have extensive privacy policies and get into less trouble with increasingly common data collection laws.

@dpi dpi changed the title Cannot login with user:read scope and no public emails Lessen required scopes Apr 30, 2023
@shadowhand
Copy link
Member

That is a valid request. TBH, I haven't looked over the relevant changes that closely, but it certainly seems that we have drifted into territory where email has become a (soft) requirement.

If you would like to put together a PR, that would be appreciated. Otherwise, I will get to this when I have free time.

@dpi
Copy link
Author

dpi commented Apr 25, 2024

Posted #25 for further discussion

@distantnative
Copy link

Running into the same problem. Having the email as hard requirement (not so soft when an exception is thrown) is not great in terms of privacy etc.

@shadowhand any update whether this introduced requirement can be reverted again? Thanks for your work.

@Jefferson49
Copy link
Contributor

I ran into the same issue, while trying to access a Github user profile without public email address.

During debugging, I recognized that the root cause for this issue is a type in the default scope:

In (#26), I provided a pullrequest , which fixes this issue.

@shadowhand
Copy link
Member

Fixed in version 3.1.1.

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

Successfully merging a pull request may close this issue.

4 participants