Class SimpleApiAuthorizationProvider
- java.lang.Object
-
- de.sonallux.spotify.api.authorization.SimpleApiAuthorizationProvider
-
- All Implemented Interfaces:
ApiAuthorizationProvider
public class SimpleApiAuthorizationProvider extends Object implements ApiAuthorizationProvider
A simpleApiAuthorizationProviderthat 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 Summary
Constructors Constructor Description SimpleApiAuthorizationProvider()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetAuthorizationHeaderValue()Get the value for theAuthorizationheader that should be added to a request.booleanrefreshAccessToken()Callback to initiate a token refresh after a 401 Unauthorized response from the Spotify Web API.
-
-
-
Method Detail
-
getAuthorizationHeaderValue
public String getAuthorizationHeaderValue()
Description copied from interface:ApiAuthorizationProviderGet the value for theAuthorizationheader 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 noAuthorizationheader should be added to the requestnullcan be returned.- Specified by:
getAuthorizationHeaderValuein interfaceApiAuthorizationProvider- Returns:
- the value of the
Authorizationheader ornull
-
refreshAccessToken
public boolean refreshAccessToken()
Description copied from interface:ApiAuthorizationProviderCallback to initiate a token refresh after a 401 Unauthorized response from the Spotify Web API. If this operation is not supported or failed, returnfalse. A return value oftrueindicates that the failing request should be retried. TheApiAuthorizationProvider.getAuthorizationHeaderValue()method will be called again to get the new header with the new token- Specified by:
refreshAccessTokenin interfaceApiAuthorizationProvider- Returns:
trueto indicate to successful token refresh, otherwisefalse
-
-