Manager icon indicating copy to clipboard operation
Manager copied to clipboard

Introduce refresh and revoke interfaces for OAuth2 providers

Open ragulka opened this issue 2 years ago • 2 comments

This PR proposes 2 new interfaces:

  • RefreshTokensInterface - can be implemented by OAuth2 providers that support refreshing an access token
  • RevokeTokensInterface - 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:

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() and getRevokeTokenUrl() 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?

ragulka avatar Jun 01 '23 08:06 ragulka

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.

stale[bot] avatar Aug 12 '23 03:08 stale[bot]

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.

stale[bot] avatar Dec 15 '23 06:12 stale[bot]