Introduce refresh and revoke interfaces for OAuth2 providers
This PR proposes 2 new interfaces:
RefreshTokensInterface- can be implemented by OAuth2 providers that support refreshing an access tokenRevokeTokensInterface- can be implemented by OAuth2 providers that support revoking an access/refresh token
The interfaces are based on the current implementations in SocialiteProviders/Providers repo.
For reasoning, see this discussion.
Refreshing tokens:
- Apple refreshToken
- OKTA getRefreshTokenResponse
- Onelogin getRefreshTokenResponse
- Procore getRefreshTokenResponse
Revoking tokens:
Both interfaces define 2 methods - one for getting the raw response, the other for getting the parsed response. The reason for this is to provide backwards compatibility with existing implementations. For example, if Apple provider will implement the RefreshTokensInterface, the existing refreshToken method will continue to work as-is, so if a Laravel site is calling this method, it will continue to work.
Ideally, the implementation of the parsed response method is to call the raw response method and parse the response, ie:
public function getRefreshTokenResponse(string $refreshToken) : array {
return json_decode((string) $this->refreshToken($refreshToken)->getBody(), true);
}
Other considerations / open questions
- Should we define
getRefreshTokenUrl()andgetRevokeTokenUrl()methods? Some existing providers define such methods, but having these in the contract would make sense if we also provide a trait that implements these methods. - Tied to the above - should we have matching traits that implement both interfaces?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.