ProviderInterface.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace Overtrue\Socialite\Contracts;
  3. /** @see https://datatracker.ietf.org/doc/html/rfc6749#appendix-A.1 */
  4. const RFC6749_ABNF_CLIENT_ID = 'client_id';
  5. /** @see https://datatracker.ietf.org/doc/html/rfc6749#appendix-A.2 */
  6. const RFC6749_ABNF_CLIENT_SECRET = 'client_secret';
  7. /** @see https://datatracker.ietf.org/doc/html/rfc6749#appendix-A.3 */
  8. const RFC6749_ABNF_RESPONSE_TYPE = 'response_type';
  9. /** @see https://datatracker.ietf.org/doc/html/rfc6749#appendix-A.4 */
  10. const RFC6749_ABNF_SCOPE = 'scope';
  11. /** @see https://datatracker.ietf.org/doc/html/rfc6749#appendix-A.5 */
  12. const RFC6749_ABNF_STATE = 'state';
  13. /** @see https://datatracker.ietf.org/doc/html/rfc6749#appendix-A.6 */
  14. const RFC6749_ABNF_REDIRECT_URI = 'redirect_uri';
  15. /** @see https://datatracker.ietf.org/doc/html/rfc6749#appendix-A.7 */
  16. const RFC6749_ABNF_ERROR = 'error';
  17. /** @see https://datatracker.ietf.org/doc/html/rfc6749#appendix-A.8 */
  18. const RFC6749_ABNF_ERROR_DESCRIPTION = 'error_description';
  19. /** @see https://datatracker.ietf.org/doc/html/rfc6749#appendix-A.9 */
  20. const RFC6749_ABNF_ERROR_URI = 'error_uri';
  21. /** @see https://datatracker.ietf.org/doc/html/rfc6749#appendix-A.10 */
  22. const RFC6749_ABNF_GRANT_TYPE = 'grant_type';
  23. /** @see https://datatracker.ietf.org/doc/html/rfc6749#appendix-A.11 */
  24. const RFC6749_ABNF_CODE = 'code';
  25. /** @see https://datatracker.ietf.org/doc/html/rfc6749#appendix-A.12 */
  26. const RFC6749_ABNF_ACCESS_TOKEN = 'access_token';
  27. /** @see https://datatracker.ietf.org/doc/html/rfc6749#appendix-A.13 */
  28. const RFC6749_ABNF_TOKEN_TYPE = 'token_type';
  29. /** @see https://datatracker.ietf.org/doc/html/rfc6749#appendix-A.14 */
  30. const RFC6749_ABNF_EXPIRES_IN = 'expires_in';
  31. /** @see https://datatracker.ietf.org/doc/html/rfc6749#appendix-A.15 */
  32. const RFC6749_ABNF_USERNAME = 'username';
  33. /** @see https://datatracker.ietf.org/doc/html/rfc6749#appendix-A.16 */
  34. const RFC6749_ABNF_PASSWORD = 'password';
  35. /** @see https://datatracker.ietf.org/doc/html/rfc6749#appendix-A.17 */
  36. const RFC6749_ABNF_REFRESH_TOKEN = 'refresh_token';
  37. /** @see https://datatracker.ietf.org/doc/html/rfc6749#section-4.1.3 */
  38. const RFC6749_ABNF_AUTHORATION_CODE = 'authorization_code';
  39. /** @see https://datatracker.ietf.org/doc/html/rfc6749#section-4.4.2 */
  40. const RFC6749_ABNF_CLIENT_CREDENTIALS = 'client_credentials';
  41. interface ProviderInterface
  42. {
  43. public function redirect(?string $redirectUrl = null): string;
  44. public function userFromCode(string $code): UserInterface;
  45. public function userFromToken(string $token): UserInterface;
  46. public function withRedirectUrl(string $redirectUrl): self;
  47. public function withState(string $state): self;
  48. /**
  49. * @param string[] $scopes
  50. */
  51. public function scopes(array $scopes): self;
  52. public function with(array $parameters): self;
  53. public function withScopeSeparator(string $scopeSeparator): self;
  54. public function getClientId(): ?string;
  55. public function getClientSecret(): ?string;
  56. }