Search in sources :

Example 16 with SpotifyWebApiException

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

the class GetTrackExample method getTrack_Sync.

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

Example 17 with SpotifyWebApiException

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

the class GetUsersProfileExample method getUsersProfile_Sync.

public static void getUsersProfile_Sync() {
    try {
        final User user = getUsersProfileRequest.execute();
        System.out.println("Display name: " + user.getDisplayName());
    } catch (IOException | SpotifyWebApiException | ParseException e) {
        System.out.println("Error: " + e.getMessage());
    }
}
Also used : User(se.michaelthelin.spotify.model_objects.specification.User) IOException(java.io.IOException) ParseException(org.apache.hc.core5.http.ParseException) SpotifyWebApiException(se.michaelthelin.spotify.exceptions.SpotifyWebApiException)

Example 18 with SpotifyWebApiException

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

the class AuthorizationCodePKCEExample method authorizationCode_Sync.

public static void authorizationCode_Sync() {
    try {
        final AuthorizationCodeCredentials authorizationCodeCredentials = authorizationCodePKCERequest.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 19 with SpotifyWebApiException

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

the class GetAlbumExample method getAlbum_Sync.

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

Example 20 with SpotifyWebApiException

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

the class AuthorizationCodeExample method authorizationCode_Sync.

public static void authorizationCode_Sync() {
    try {
        final AuthorizationCodeCredentials authorizationCodeCredentials = authorizationCodeRequest.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)

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