TokenStorageInterface.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. namespace OAuth\Common\Storage;
  3. use OAuth\Common\Token\TokenInterface;
  4. use OAuth\Common\Storage\Exception\TokenNotFoundException;
  5. /**
  6. * All token storage providers must implement this interface.
  7. */
  8. interface TokenStorageInterface
  9. {
  10. /**
  11. * @param string $service
  12. *
  13. * @return TokenInterface
  14. *
  15. * @throws TokenNotFoundException
  16. */
  17. public function retrieveAccessToken($service);
  18. /**
  19. * @param string $service
  20. * @param TokenInterface $token
  21. *
  22. * @return TokenStorageInterface
  23. */
  24. public function storeAccessToken($service, TokenInterface $token);
  25. /**
  26. * @param string $service
  27. *
  28. * @return bool
  29. */
  30. public function hasAccessToken($service);
  31. /**
  32. * Delete the users token. Aka, log out.
  33. *
  34. * @param string $service
  35. *
  36. * @return TokenStorageInterface
  37. */
  38. public function clearToken($service);
  39. /**
  40. * Delete *ALL* user tokens. Use with care. Most of the time you will likely
  41. * want to use clearToken() instead.
  42. *
  43. * @return TokenStorageInterface
  44. */
  45. public function clearAllTokens();
  46. /**
  47. * Store the authorization state related to a given service
  48. *
  49. * @param string $service
  50. * @param string $state
  51. *
  52. * @return TokenStorageInterface
  53. */
  54. public function storeAuthorizationState($service, $state);
  55. /**
  56. * Check if an authorization state for a given service exists
  57. *
  58. * @param string $service
  59. *
  60. * @return bool
  61. */
  62. public function hasAuthorizationState($service);
  63. /**
  64. * Retrieve the authorization state for a given service
  65. *
  66. * @param string $service
  67. *
  68. * @return string
  69. */
  70. public function retrieveAuthorizationState($service);
  71. /**
  72. * Clear the authorization state of a given service
  73. *
  74. * @param string $service
  75. *
  76. * @return TokenStorageInterface
  77. */
  78. public function clearAuthorizationState($service);
  79. /**
  80. * Delete *ALL* user authorization states. Use with care. Most of the time you will likely
  81. * want to use clearAuthorization() instead.
  82. *
  83. * @return TokenStorageInterface
  84. */
  85. public function clearAllAuthorizationStates();
  86. }