de.sonallux.spotify.api.authorization.TokenStoreApiAuthorizationProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spotify-web-api-java Show documentation
Show all versions of spotify-web-api-java Show documentation
A Java wrapper for Spotify's Web API
The newest version!
package de.sonallux.spotify.api.authorization;
import de.sonallux.spotify.api.util.TextUtil;
import lombok.AllArgsConstructor;
/**
* An {@link ApiAuthorizationProvider} that uses a provided {@link TokenStore} to provide authorization
*/
@AllArgsConstructor
public class TokenStoreApiAuthorizationProvider implements ApiAuthorizationProvider{
protected final TokenStore tokenStore;
@Override
public String getAuthorizationHeaderValue() {
var tokens = tokenStore.loadTokens();
if (tokens == null || !TextUtil.hasText(tokens.getAccessToken()) || !TextUtil.hasText(tokens.getTokenType())) {
return null;
}
return tokens.getTokenType() + " " + tokens.getAccessToken();
}
@Override
public boolean refreshAccessToken() {
return false;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy