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

Introduce refresh and revoke interfaces for OAuth2 providers #218

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ragulka
Copy link

@ragulka ragulka commented Jun 1, 2023

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?

@stale
Copy link

stale bot commented Aug 12, 2023

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 stale bot added the stale label Aug 12, 2023
@atymic atymic removed the stale label Sep 7, 2023
Copy link

stale bot commented Dec 15, 2023

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 stale bot added the stale label Dec 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants