Class TokenStoreApiAuthorizationProvider

java.lang.Object
de.sonallux.spotify.api.authorization.TokenStoreApiAuthorizationProvider
All Implemented Interfaces:
ApiAuthorizationProvider
Direct Known Subclasses:
AuthorizationCodeFlow, AuthorizationCodePKCEFlow, ClientCredentialsFlow, ImplicitGrantFlow

public class TokenStoreApiAuthorizationProvider extends Object implements ApiAuthorizationProvider
An ApiAuthorizationProvider that uses a provided TokenStore to provide authorization
  • Field Details

    • tokenStore

      protected final TokenStore tokenStore
  • Constructor Details

    • TokenStoreApiAuthorizationProvider

      public TokenStoreApiAuthorizationProvider()
  • Method Details

    • getAuthorizationHeaderValue

      public String getAuthorizationHeaderValue()
      Description copied from interface: ApiAuthorizationProvider
      Get the value for the Authorization header that should be added to a request. This method will be called for every request, so always the latest authentication token can be used. If no Authorization header should be added to the request null can be returned.
      Specified by:
      getAuthorizationHeaderValue in interface ApiAuthorizationProvider
      Returns:
      the value of the Authorization header or null
    • refreshAccessToken

      public boolean refreshAccessToken()
      Description copied from interface: ApiAuthorizationProvider
      Callback to initiate a token refresh after a 401 Unauthorized response from the Spotify Web API. If this operation is not supported or failed, return false. A return value of true indicates that the failing request should be retried. The ApiAuthorizationProvider.getAuthorizationHeaderValue() method will be called again to get the new header with the new token
      Specified by:
      refreshAccessToken in interface ApiAuthorizationProvider
      Returns:
      true to indicate to successful token refresh, otherwise false