Class SimpleApiAuthorizationProvider
java.lang.Object
de.sonallux.spotify.api.authorization.SimpleApiAuthorizationProvider
- All Implemented Interfaces:
ApiAuthorizationProvider
A simple
This class is useful if you already have an access token.
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGet the value for theAuthorizationheader that should be added to a request.booleanCallback to initiate a token refresh after a 401 Unauthorized response from the Spotify Web API.
-
Constructor Details
-
SimpleApiAuthorizationProvider
public SimpleApiAuthorizationProvider()
-
-
Method Details
-
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
-