de.sonallux.spotify.api.authorization.SimpleApiAuthorizationProvider 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;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
/**
* A simple {@link 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.
*/
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class SimpleApiAuthorizationProvider implements ApiAuthorizationProvider {
private static final String TOKEN_TYPE = "Bearer";
private String accessToken;
@Override
public String getAuthorizationHeaderValue() {
if (!TextUtil.hasText(accessToken)) {
return null;
}
return TOKEN_TYPE + " " + accessToken;
}
@Override
public boolean refreshAccessToken() {
return false;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy