thephpleague / oauth2-client

Easy integration with OAuth 2.0 service providers.
http://oauth2-client.thephpleague.com
MIT License
3.64k stars 751 forks source link

Add original oauth error to IdentityProviderException #969

Open uncaught opened 2 years ago

uncaught commented 2 years ago

I would like to ask to add a new getter/setter to the IdentityProviderException so that you and other libraries can provide accurate access to the original oauth error.

I'm talking about the error strings described in https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-20#section-5.2, like invalid_grant.

Accessing this underlying error might be quite important when handling the status of a connected account, but currently it is unclear how to retrieve it. Especially since I intend to implement several providers with KnpU\OAuth2ClientBundle.

I ran into this problem because TheNetworg/oauth2-azure concated that error with the error description, giving me no real access.

It might even be prudent to create a new exception with that error field required. And only allow exactly the spec-defined values.

Of course by the time this is implemented and all the other libraries adopted it, my software will be long done. But I hope this might help someone in the future.