Search in sources :

Example 21 with SpotifyWebApiException

use of se.michaelthelin.spotify.exceptions.SpotifyWebApiException in project spotify-web-api-java by spotify-web-api-java.

the class AuthorizationCodePKCERefreshExample method authorizationCodeRefresh_Sync.

public static void authorizationCodeRefresh_Sync() {
    try {
        final AuthorizationCodeCredentials authorizationCodeCredentials = authorizationCodePKCERefreshRequest.execute();
        // Set access and refresh token for further "spotifyApi" object usage
        spotifyApi.setAccessToken(authorizationCodeCredentials.getAccessToken());
        spotifyApi.setRefreshToken(authorizationCodeCredentials.getRefreshToken());
        System.out.println("Expires in: " + authorizationCodeCredentials.getExpiresIn());
    } catch (IOException | SpotifyWebApiException | ParseException e) {
        System.out.println("Error: " + e.getMessage());
    }
}
Also used : IOException(java.io.IOException) ParseException(org.apache.hc.core5.http.ParseException) SpotifyWebApiException(se.michaelthelin.spotify.exceptions.SpotifyWebApiException) AuthorizationCodeCredentials(se.michaelthelin.spotify.model_objects.credentials.AuthorizationCodeCredentials)

Example 22 with SpotifyWebApiException

use of se.michaelthelin.spotify.exceptions.SpotifyWebApiException 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());
    }
}
Also used : IOException(java.io.IOException) ParseException(org.apache.hc.core5.http.ParseException) ClientCredentials(se.michaelthelin.spotify.model_objects.credentials.ClientCredentials) SpotifyWebApiException(se.michaelthelin.spotify.exceptions.SpotifyWebApiException)

Example 23 with SpotifyWebApiException

use of se.michaelthelin.spotify.exceptions.SpotifyWebApiException in project spotify-web-api-java by spotify-web-api-java.

the class GetUsersCurrentlyPlayingTrackExample method getUsersCurrentlyPlayingTrack_Sync.

public static void getUsersCurrentlyPlayingTrack_Sync() {
    try {
        final CurrentlyPlaying currentlyPlaying = getUsersCurrentlyPlayingTrackRequest.execute();
        System.out.println("Timestamp: " + currentlyPlaying.getTimestamp());
    } catch (IOException | SpotifyWebApiException | ParseException e) {
        System.out.println("Error: " + e.getMessage());
    }
}
Also used : CurrentlyPlaying(se.michaelthelin.spotify.model_objects.miscellaneous.CurrentlyPlaying) IOException(java.io.IOException) ParseException(org.apache.hc.core5.http.ParseException) SpotifyWebApiException(se.michaelthelin.spotify.exceptions.SpotifyWebApiException)

Example 24 with SpotifyWebApiException

use of se.michaelthelin.spotify.exceptions.SpotifyWebApiException in project spotify-web-api-java by spotify-web-api-java.

the class GetShowExample method getShow_Sync.

public static void getShow_Sync() {
    try {
        final Show show = getShowRequest.execute();
        System.out.println("Name: " + show.getName());
    } catch (IOException | SpotifyWebApiException | ParseException e) {
        System.out.println("Error: " + e.getMessage());
    }
}
Also used : Show(se.michaelthelin.spotify.model_objects.specification.Show) IOException(java.io.IOException) ParseException(org.apache.hc.core5.http.ParseException) SpotifyWebApiException(se.michaelthelin.spotify.exceptions.SpotifyWebApiException)

Example 25 with SpotifyWebApiException

use of se.michaelthelin.spotify.exceptions.SpotifyWebApiException in project spotify-web-api-java by spotify-web-api-java.

the class ReorderPlaylistsItemsExample method reorderPlaylistsItems_Sync.

public static void reorderPlaylistsItems_Sync() {
    try {
        final SnapshotResult snapshotResult = reorderPlaylistsItemsRequest.execute();
        System.out.println("Snapshot ID: " + snapshotResult.getSnapshotId());
    } catch (IOException | SpotifyWebApiException | ParseException e) {
        System.out.println("Error: " + e.getMessage());
    }
}
Also used : SnapshotResult(se.michaelthelin.spotify.model_objects.special.SnapshotResult) IOException(java.io.IOException) ParseException(org.apache.hc.core5.http.ParseException) SpotifyWebApiException(se.michaelthelin.spotify.exceptions.SpotifyWebApiException)

Aggregations

IOException (java.io.IOException)27 ParseException (org.apache.hc.core5.http.ParseException)27 SpotifyWebApiException (se.michaelthelin.spotify.exceptions.SpotifyWebApiException)27 AuthorizationCodeCredentials (se.michaelthelin.spotify.model_objects.credentials.AuthorizationCodeCredentials)5 SnapshotResult (se.michaelthelin.spotify.model_objects.special.SnapshotResult)3 Playlist (se.michaelthelin.spotify.model_objects.specification.Playlist)3 User (se.michaelthelin.spotify.model_objects.specification.User)2 SpotifyToYoutubeInterpreter (de.lundy.lobster.lavaplayer.spotify.SpotifyToYoutubeInterpreter)1 BotInstanceManagementService (de.notecho.spotify.bot.BotInstanceManagementService)1 BaseModule (de.notecho.spotify.bot.modules.BaseModule)1 TokenPair (de.notecho.spotify.database.user.entities.TokenPair)1 UserRepository (de.notecho.spotify.database.user.repository.UserRepository)1 BadRequestException (se.michaelthelin.spotify.exceptions.detailed.BadRequestException)1 ClientCredentials (se.michaelthelin.spotify.model_objects.credentials.ClientCredentials)1 AudioAnalysis (se.michaelthelin.spotify.model_objects.miscellaneous.AudioAnalysis)1 CurrentlyPlaying (se.michaelthelin.spotify.model_objects.miscellaneous.CurrentlyPlaying)1 CurrentlyPlayingContext (se.michaelthelin.spotify.model_objects.miscellaneous.CurrentlyPlayingContext)1 FeaturedPlaylists (se.michaelthelin.spotify.model_objects.special.FeaturedPlaylists)1 SearchResult (se.michaelthelin.spotify.model_objects.special.SearchResult)1 Album (se.michaelthelin.spotify.model_objects.specification.Album)1