Class SimpleApiAuthorizationProvider

java.lang.Object
de.sonallux.spotify.api.authorization.SimpleApiAuthorizationProvider
All Implemented Interfaces:
ApiAuthorizationProvider

public class SimpleApiAuthorizationProvider extends Object implements ApiAuthorizationProvider
A simple ApiAuthorizationProvider that can only hold an access token. It does not support any authorization specific logic such as refreshing a token.
This class is useful if you already have an access token.
  • Constructor Details

    • SimpleApiAuthorizationProvider

      public SimpleApiAuthorizationProvider()
  • 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