use of se.michaelthelin.spotify.model_objects.credentials.ClientCredentials in project spotify-web-api-java by spotify-web-api-java.
the class ClientCredentialsExample method clientCredentials_Async.
public static void clientCredentials_Async() {
try {
final CompletableFuture<ClientCredentials> clientCredentialsFuture = clientCredentialsRequest.executeAsync();
// Thread free to do other tasks...
// Example Only. Never block in production code.
final ClientCredentials clientCredentials = clientCredentialsFuture.join();
// Set access token for further "spotifyApi" object usage
spotifyApi.setAccessToken(clientCredentials.getAccessToken());
System.out.println("Expires in: " + clientCredentials.getExpiresIn());
} catch (CompletionException e) {
System.out.println("Error: " + e.getCause().getMessage());
} catch (CancellationException e) {
System.out.println("Async operation cancelled.");
}
}
use of se.michaelthelin.spotify.model_objects.credentials.ClientCredentials in project spotify-web-api-java by spotify-web-api-java.
the class ClientCredentialsExample method clientCredentials_Sync.
public static void clientCredentials_Sync() {
try {
final ClientCredentials clientCredentials = clientCredentialsRequest.execute();
// Set access token for further "spotifyApi" object usage
spotifyApi.setAccessToken(clientCredentials.getAccessToken());
System.out.println("Expires in: " + clientCredentials.getExpiresIn());
} catch (IOException | SpotifyWebApiException | ParseException e) {
System.out.println("Error: " + e.getMessage());
}
}
Aggregations