RefreshTokenInterface.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. namespace OAuth2\Storage;
  3. /**
  4. * Implement this interface to specify where the OAuth2 Server
  5. * should get/save refresh tokens for the "Refresh Token"
  6. * grant type
  7. *
  8. * @author Brent Shaffer <bshafs at gmail dot com>
  9. */
  10. interface RefreshTokenInterface
  11. {
  12. /**
  13. * Grant refresh access tokens.
  14. *
  15. * Retrieve the stored data for the given refresh token.
  16. *
  17. * Required for OAuth2::GRANT_TYPE_REFRESH_TOKEN.
  18. *
  19. * @param $refresh_token
  20. * Refresh token to be check with.
  21. *
  22. * @return
  23. * An associative array as below, and NULL if the refresh_token is
  24. * invalid:
  25. * - refresh_token: Refresh token identifier.
  26. * - client_id: Client identifier.
  27. * - user_id: User identifier.
  28. * - expires: Expiration unix timestamp, or 0 if the token doesn't expire.
  29. * - scope: (optional) Scope values in space-separated string.
  30. *
  31. * @see http://tools.ietf.org/html/rfc6749#section-6
  32. *
  33. * @ingroup oauth2_section_6
  34. */
  35. public function getRefreshToken($refresh_token);
  36. /**
  37. * Take the provided refresh token values and store them somewhere.
  38. *
  39. * This function should be the storage counterpart to getRefreshToken().
  40. *
  41. * If storage fails for some reason, we're not currently checking for
  42. * any sort of success/failure, so you should bail out of the script
  43. * and provide a descriptive fail message.
  44. *
  45. * Required for OAuth2::GRANT_TYPE_REFRESH_TOKEN.
  46. *
  47. * @param $refresh_token
  48. * Refresh token to be stored.
  49. * @param $client_id
  50. * Client identifier to be stored.
  51. * @param $user_id
  52. * User identifier to be stored.
  53. * @param $expires
  54. * Expiration timestamp to be stored. 0 if the token doesn't expire.
  55. * @param $scope
  56. * (optional) Scopes to be stored in space-separated string.
  57. *
  58. * @ingroup oauth2_section_6
  59. */
  60. public function setRefreshToken($refresh_token, $client_id, $user_id, $expires, $scope = null);
  61. /**
  62. * Expire a used refresh token.
  63. *
  64. * This is not explicitly required in the spec, but is almost implied.
  65. * After granting a new refresh token, the old one is no longer useful and
  66. * so should be forcibly expired in the data store so it can't be used again.
  67. *
  68. * If storage fails for some reason, we're not currently checking for
  69. * any sort of success/failure, so you should bail out of the script
  70. * and provide a descriptive fail message.
  71. *
  72. * @param $refresh_token
  73. * Refresh token to be expired.
  74. *
  75. * @ingroup oauth2_section_6
  76. */
  77. public function unsetRefreshToken($refresh_token);
  78. }