Class TokenStoreApiAuthorizationProvider
java.lang.Object
de.sonallux.spotify.api.authorization.TokenStoreApiAuthorizationProvider
- All Implemented Interfaces:
ApiAuthorizationProvider
- Direct Known Subclasses:
AuthorizationCodeFlow,AuthorizationCodePKCEFlow,ClientCredentialsFlow,ImplicitGrantFlow
An
ApiAuthorizationProvider that uses a provided TokenStore to provide authorization-
Field Summary
Fields -
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.
-
Field Details
-
tokenStore
-
-
Constructor Details
-
TokenStoreApiAuthorizationProvider
public TokenStoreApiAuthorizationProvider()
-
-
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
-