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
AnApiAuthorizationProviderthat uses a providedTokenStoreto provide authorization
-
-
Field Summary
Fields Modifier and Type Field Description protected TokenStoretokenStore
-
Constructor Summary
Constructors Constructor Description TokenStoreApiAuthorizationProvider()
-
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.
-
-
-
Field Detail
-
tokenStore
protected final TokenStore tokenStore
-
-
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
-
-