Giter Site home page Giter Site logo

spotify-web-api-java's Introduction

Everyone – One click to help!
Please upvote this Spotify community issue to ensure maintenance for this repository remains possible!
Android Developers
You cannot use this library for Android app development. Have a look at adamint/spotify-web-api-kotlin, kaaes/spotify-web-api-android and Spotify's Android SDK and see why.

Spotify Web API Java

CI codecov

This is a Java wrapper/client for the Spotify Web API.

Table of Contents

  1. Installation
    1. Jitpack
  2. Documentation
  3. General Usage
    1. Authorization
  4. Examples
  5. Contributions
    1. Code Overview

Installation

The artifact is available through Maven Central via Sonatype. Or to use a snapshot of the latest commit you can use jitpack.io as described further down below.

Maven

Latest official release:

<dependency>
  <groupId>se.michaelthelin.spotify</groupId>
  <artifactId>spotify-web-api-java</artifactId>
  <version>8.4.0</version>
</dependency>

Latest snapshot:

<dependency>
  <groupId>com.github.thelinmichael</groupId>
  <artifactId>spotify-web-api-java</artifactId>
  <version>master-SNAPSHOT</version>
</dependency>

Gradle

Latest official release:

implementation 'se.michaelthelin.spotify:spotify-web-api-java:8.4.0'

Latest snapshot:

implementation 'com.github.thelinmichael:spotify-web-api-java:master-SNAPSHOT'

Jitpack

In order to use Jitpack you need to add their repository to your pom.xml:

Maven

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

Gradle

allprojects {
    repositories {
        maven { url 'https://jitpack.io' }
    }
}

Documentation

See this project's Javadoc.

A huge thanks to c-schuhmann for his amazing work on the documentation!

General Usage

// For all requests an access token is needed
SpotifyApi spotifyApi = new SpotifyApi.Builder()
        .setAccessToken("taHZ2SdB-bPA3FsK3D7ZN5npZS47cMy-IEySVEGttOhXmqaVAIo0ESvTCLjLBifhHOHOIuhFUKPW1WMDP7w6dj3MAZdWT8CLI2MkZaXbYLTeoDvXesf2eeiLYPBGdx8tIwQJKgV8XdnzH_DONk")
        .build();

// Create a request object with the optional parameter "market"
final GetSomethingRequest getSomethingRequest = spotifyApi.getSomething("qKRpDADUKrFeKhFHDMdfcu")
        .market(CountryCode.SE)
        .build();

void getSomething_Sync() {
  try {
    // Execute the request synchronous
    final Something something = getSomethingRequest.execute();

    // Print something's name
    System.out.println("Name: " + something.getName());
  } catch (Exception e) {
    System.out.println("Something went wrong!\n" + e.getMessage());
  }
}

void getSomething_Async() {
  try {
    // Execute the request asynchronous
    final Future<Something> somethingFuture = getSomethingRequest.executeAsync();

    // Do other things...

    // Wait for the request to complete
    final Something something = somethingFuture.get();

    // Print something's name
    System.out.println("Name: " + something.getName());
  } catch (Exception e) {
    System.out.println("Something went wrong!\n" + e.getMessage());
  }
}

Authorization

Please see Spotify's Authorization Guide too!

For authorization requests the API object requires at least to have your application's client ID and client secret set as its properties. When using the authorization code flow, the application's redirect URI is required too. Those properties will then be automatically used by functions that depend on them.

SpotifyApi spotifyApi = new SpotifyApi.Builder()
  .setClientId("<your_client_id>")
  .setClientSecret("<your_client_secret>")
  .setRedirectUri("<your_redirect_uri>")
  .build();

There are three ways to retrieving an access token:

Use the client credentials flow when the requests don't require permission from a specific user. This flow doesn't return a refresh token and is useful for simple requests, like fetching albums or searching for tracks.

Example: ClientCredentialsExample.java

Using the authorization code flow to retrieve an access token is necessary if the requests are bound to a specific user. Using this flow returns a refresh token, which can be used to renew the access token before it expires. This is how it works:

  1. The authorization code flow requires a code, which is part of the redirectUri's query parameters when the user has opened a custom URL in a browser and authorized the application.

    Example: AuthorizationCodeUriExample.java

  2. When the code has been retrieved, it can be used in another request to get an access token as well as a refresh token.

    Example: AuthorizationCodeExample.java

  3. Now, the refresh token in turn can be used in a loop to retrieve new access and refresh tokens.

    Example: AuthorizationCodeRefreshExample.java


When you've fetched an access and refresh token, you have to add them to your API properties for automatic usage in requests. The implementer has to handle the access token's expiration.

spotifyApi
  .setAccessToken("<your_access_token>")
  .setRefreshToken("<your_refresh_token>")
  .build();

The authorization code flow with PKCE is quite like the Authorization Code Flow except that no client secret is necessary (therefore, it is a good option for mobile and desktop applications). Instead, your application should generate a code verifier and a code challenge before each authentication request.

The code verifier is a cryptographically random string between 43 and 128 characters in length. It can contain letters, digits, underscores, periods, hyphens, or tildes. To generate the code challenge, your app should hash the code verifier using the SHA256 algorithm. Then, base64url encode the hash that you generated.

This flow provides your app with an access token which can be refreshed, too. The steps are similar as above:

  1. The authorization code flow with PKCE requires a code, which is part of the redirectUri's query parameters when the user has opened a custom URL in a browser and authorized the application. The code challenge is supplied to this request as a query parameter.

    Example: AuthorizationCodePKCEUriExample.java

  2. When the code has been retrieved, it can be used in another request to get an access token as well as a refresh token. The code verifier is supplied to this request a query parameter.

    Example: AuthorizationCodePKCEExample.java

  3. Now, the refresh token in turn can be used in a loop to retrieve new access and refresh tokens.

    Example: AuthorizationCodePKCERefreshExample.java


When you have fetched an access and refresh token, you have to add them to your API properties for automatic usage in requests. The implementer must handle the access token's expiration. The refresh token can be exchanged for an access token only once, after which it becomes invalid.

Examples

Contributions

See CONTRIBUTING.md.

  • Build: mvn clean install
  • Test: mvn clean test

Requirements: Java, Maven.

Code Overview

This project's main Java package is divided into four sections:

  • enumerations
  • exceptions
  • model objects
  • requests.

Those unit-tested parts are connected through various classes that make the API accessible for other Java projects. You can find details about specific parts or single classes in the sections below.

Enumerations

src/main/java/se.michaelthelin.spotify/enums/

Enumerations allow elements to "be of a type" and limit them to a known value set. They are currently not specified in a unique place, but are rather scrambled across the online reference. Thus, the reference only allows for construction of enum classes from this sparse information.

Exceptions

src/main/java/se.michaelthelin.spotify/exceptions/

Exceptions are thrown when errors occur. They are following RFC-specified HTTP status codes and are packed with a more detailed error description.

Model Objects

src/main/java/se.michaelthelin.spotify/model_objects/

The model objects are entities that form the API's responses in arranged formats. They are mostly specified in the Web API Object Model and in the Web API Authorization Guide. Though, unreferenced model objects exist. This project subdivides those into...

  • "miscellaneous" model objects: these are mentioned somewhere in the reference, but not in the model object list
  • "special" model objects: these are not mentioned at all, but appear in API answers nonetheless.

Java classes representing those model objects include private instance variables, a private constructor, but public getter methods as well as an embedded...

  1. builder class, including the setter functions and a public build method
  2. JSON-util class, implementing the createModelObject method.

Requests

src/main/java/se.michaelthelin.spotify/requests/

The request classes mirror the structure of Spotify's Web Api endpoints. They are divided into several categories like authorization, data/albums or data/tracks. They must extend from AbstractDataRequest and contain an implementation of the request's execute method. They have to embed a builder class too, enabling dynamic request creation.

Tests

src/test/java/se.michaelthelin.spotify/

Unit tests ensure that implemented features work. This project's unit tests are implemented with JUnit and mockito for mocking.

Fixtures

src/test/fixtures/

Fixtures are JSON files that represent the data returned from the API server. We use the examples directly provided by the Web API Endpoint Reference with minor tweaks. Tweaks are needed because the reference sometimes contains invalid data examples.

spotify-web-api-java's People

Contributors

ale-vncs avatar astronuun avatar bart1909 avatar bradnussbaum avatar c-schuhmann avatar carterbuce avatar dargmuesli avatar dependabot[bot] avatar duncte123 avatar ezienecker avatar hwup avatar ironyarddoug avatar jdngray77 avatar jonasfugedi avatar jpfrehe avatar kingnaldojr avatar kschow avatar leojcollard avatar me-heer avatar mureinik avatar renovate-bot avatar renovate[bot] avatar selbi182 avatar sergiobarbero avatar sprokopets avatar t-fowl avatar tamboor avatar thelinmichael avatar wagnerchristoph avatar waynee95 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

spotify-web-api-java's Issues

Support cache-control headers

It would be great to be able to cache results of the API. Therefore the Cache-Control and ETag headers would need to be supported.

https://developer.spotify.com/web-api/user-guide/ section "Conditional requests"

Most API responses come with appropriate cache-control headers set to assist in client-side caching. If you have cached a response, do not request again until the response has expired; if the response contains an ETag, set the If-None-Match request header to the ETag value. If the response hasn’t changed, the Spotify service will respond quickly with the 304 Not Modified status (i.e., your cached version is still good and your application should use it).

Api.getStarred(String user) deprecated

A while ago Spotify changed their starred tracks behaviour and seemed to have removed the API call to /v1/users/{userId}/starred/tracks. You will now get the starred tracks from a user playlist called "Starred".

Calling Api.getStarred(String user) will therefore cause an Exception

Getting current user crashes program.

CurrentUserRequest spotifyMe = api.getMe().build();
com.wrapper.spotify.models.User spotifyUser = spotifyMe.get();

this will crash the program if the product returned is "open" which is still a possible response. I think a new enum can be added to the product model but i have no time to look at where else this is used because im busy with class. Any help would be greatly appreciated.

If playlist contains local files, request.get() returns empty Page

If you have a playlist with files that you add from your computer, you cannot retrieve it through the api as it does not support them (?). When you try to, it just returns an empty track list. However, this only occurs if you request for the part that the local file is in, i.e. if it is the 101th song and you request the first 100 it still works, but for the 101th song request it returns empty. If the second request is 100 limit, the whole request is still empty even if there are non-local file songs present.

PlaylistRequest doesn't support parameters.

PlaylistRequest request = spotifyManager.api.getPlaylist(userId, playlistId).parameter("limit", "1").build();

then I go on to ask it how many artists are in the results, it gives me 3 - none of which have collaborated. I also set offsets and that doesn't work too, always starting at 0.

PlaylistRequest request = spotifyManager.api.getPlaylist(userId, playlistId).parameter("offset", "100").build();

Neither of which work.

org.apache.commons.collections.ArrayStack has already been added to output. Please remove duplicate copies

Hi Michael, don't know if you can help.

i get this error while building my app in Android Studio 1.0. In Beta 0.8.9 everythings works fine.

org.apache.commons.collections.ArrayStack has already been added to output. Please remove duplicate copies

i opened a question at stack overflow with more details.

http://stackoverflow.com/questions/27458227/org-apache-commons-collections-arraystack-has-already-been-added-to-output-plea

I also tried to start a complete new project and only added

compile 'se.michaelthelin.spotify:spotify-web-api-java:1.4.20'

to my build.gradle dependencies.

thanks for help.
Alex

*.class

Hi,

first of all: thank you very much for this library. It is really handy.

One question though: In your 1.4.1 Jar release there is a file called *.class which seems to be a zip file of the META-INF folder. When I package your jar in a webapp and run it in a tomcat8 server, I get a tomcat startup warning (see below for stacktrace). It does not break the application but is kind of distracting. Is that *.class file in there by accident or does it serve a purpose I don't see?

Cheers

Patrick

14-Nov-2014 13:26:54.103 SEVERE [RMI TCP Connection(2)-127.0.0.1] org.apache.catalina.startup.ContextConfig.processAnnotationsJar Unable to process Jar entry [*.class] from Jar [jar:file:/WEB-INF/lib/spotify-web-api-java-1.4.1.jar!/] for annotations
 org.apache.tomcat.util.bcel.classfile.ClassFormatException: null is not a Java .class file
    at org.apache.tomcat.util.bcel.classfile.ClassParser.readID(ClassParser.java:196)
    at org.apache.tomcat.util.bcel.classfile.ClassParser.parse(ClassParser.java:87)
    at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:1987)
    at org.apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:1940)
    at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1915)
    at org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:1876)
    at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1145)
    at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:767)
    at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:302)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5083)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:724)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:700)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:714)
    at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1588)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
    at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
    at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:463)
    at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:413)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
    at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
    at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1466)
    at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76)
    at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1307)
    at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1399)
    at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:828)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:323)
    at sun.rmi.transport.Transport$1.run(Transport.java:178)
    at sun.rmi.transport.Transport$1.run(Transport.java:175)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.Transport.serviceCall(Transport.java:174)
    at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:557)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:812)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:671)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

Publish a new Build to Maven Central

The pom states the current version as 1.7.1, but the newest one available at maven central is 1.5.0. Would it be possible to publish a new build to maven central, to simplify using the new version?

Getting error on Authorization Code Grant

When I try to get authoriztion, the callback is going to the method onFailure, and the error message is "null". I don't understand what is the field "code" that we have to define, and maybe this why I have error on the authorization. Can you help me? Thanks a lot.

PS: this is my code with error http://pastebin.com/X0M4qf40

Unkown Albumtype

I recently tried to load a user playlist from spotify. The user is vatrixxx and the playlist id is 0XCJhP0wvALybQsWsjSJ5M . I get an exception of the type java.lang.IllegalArgumentException: No enum constant com.wrapper.spotify.models.AlbumType.NULL. Can you change this enum?

1.5.0 jar

Did I miss something or is there any reason why the latest release (1.5.0) isn't available as jar-release?

How to use the refresh_token?

Thank you for this great api, works like a charm. i wonder how to use the refresh_token.

After the first authentication i am saving the refreshtoken in the sharedPreferences. on every start i set the refreshToken and call refreshAccessToken.
api.setRefreshToken(refreshToken);
api.refreshAccessToken();

but this does not work. i have to reauthenticate via a browser to get a fresh accessToken.

what i am doing wrong?

best regards
Alex

Multiple dex files define Lorg/apache/commons/collections/FastHashMap

I'm getting the following error on build after adding the libary to my dependencies:
compile 'se.michaelthelin.spotify:spotify-web-api-java:1.4.20'
UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define Lorg/apache/commons/collections/FastHashMap;

So I tried excluding the collections lib:
compile('se.michaelthelin.spotify:spotify-web-api-java:1.4.20') {exclude group: "commons-collections", module: "commons-collections"}
But this results in a number of errors on run such as:
E/dalvikvm﹕ Could not find class 'org.apache.commons.collections.map.ListOrderedMap', referenced from method net.sf.json.JSONObject.<init>
W/dalvikvm﹕ VFY: unable to resolve new-instance 5053 (Lorg/apache/commons/collections/map/ListOrderedMap;) in Lnet/sf/json/JSONObject;
...
E/dalvikvm﹕ Could not find class 'org.apache.commons.collections.map.MultiKeyMap', referenced from method net.sf.json.JsonConfig.<init>
W/dalvikvm﹕ VFY: unable to resolve new-instance 5054 (Lorg/apache/commons/collections/map/MultiKeyMap;) in Lnet/sf/json/JsonConfig;

when I try to do
AuthorizationCodeCredentials authorizationCodeCredentials = api.authorizationCodeGrant(code).build().get();
and return the result.

My current dependencies are the following:
dependencies { compile 'com.spotify.sdk:spotifysdk:1.0.0-beta5@aar' compile('se.michaelthelin.spotify:spotify-web-api-java:1.4.20') {exclude group: "commons-collections", module: "commons-collections"} compile 'com.android.support:support-v13:21.0.0'// NOTE: Version must match! compile files('libs/gson-2.3.1.jar') compile 'com.parse.bolts:bolts-android:1.1.3' compile fileTree(include: 'Parse-*.jar', dir: 'libs') }

'birthdate' missing from user object and response

Hi,

The 'birthdate' field, which is returned from the "Get Current User" endpoint (GET https://api.spotify.com/v1/me https://developer.spotify.com/web-api/get-current-users-profile/) doesn't seem to be supported by this library yet.

We've already built an integration using this library, and it would be great to be able to use this field, so I'm gonna give a crack at it and try to send in a PR, but figured I would drop this issue here to reference and see if anyone else has built it, or if the library owner is able to quickly fix it.

Thanks!
-Samir

API limit requets

Hi,
With our app we have reach the limit of requests we can do (429 error).
But all our requests are identified (authorization bearer), and we do retry after as possible (some times we get 404 not found in place for same requests)...

What can we do for increase this limit ?

Thanks !

Bug adding tracks to a playlist

Hi

I've been trying to add tracks to a playlist and I haven't been able to.

When I try to add a track to a playlist using the Synchronous method of the library I get a 400 error.

I've browsed the code and I've seen that it's trying to make a GET request instead of a POST request, and trying to parse the incorrect Response JSON. ( The correct Response is an empty body )

Play music from spotify

If I want to build a player, it means play a music from spotify, can I use your wrapper to do it or use the spotify android sdk instead?

Thanks a lot.

getPlaylistsForUser return empty when there are playlists

Im calling the getPlaylistsForUser as following

final Api authApi = Api.builder()
                .clientId(System.getProperty("spotify.clientId"))
                .clientSecret(System.getProperty("spotify.client"))
                .build();

final ArrayList<String> scopes = new ArrayList<>();
scopes.add("playlist-read-private");
scopes.add("playlist-read-collaborative");

final ClientCredentialsGrantRequest request = authApi.clientCredentialsGrant().scopes(scopes).build();
final ClientCredentials clientCredentials = request.get();

authApi.setAccessToken(clientCredentials.getAccessToken());

final List<SimplePlaylist> all = new ArrayList<>();

final String user = "an user id";

Page<SimplePlaylist> simplePlaylistPage = authApi.getPlaylistsForUser(user).limit(50).build().get();
List<SimplePlaylist> items = simplePlaylistPage.getItems();

// The items list is empty, even when the user has playlist. 
// I tested wusing curl and the spotify interactive console and I got results.

It is a bug or Im doing something wrong ?

Search for a Playlist

Hey Michael,

it would be great, if you could add the search for a playlist.

thanks
Alex

Libs needed

Hi,

is there a trick to get this to work?
I'm just running into one NoClassDefFoundError after another and have already downloaded and added 7 libraries.

BR
/Patrick

Build Fails on Android Studio 1.0.2

When I try to build my project, I get this error

FAILURE: Build failed with an exception.

    * What went wrong:
Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    /opt/android-sdk/build-tools/20.0.0/dx --dex --no-optimize --output     /home/brett/AndroidStudioProjects/Perkisizer/app/build/intermediates/dex/debug     /home/brett/AndroidStudioProjects/Perkisizer/app/build/intermediates/classes/debug     /home/brett/AndroidStudioProjects/Perkisizer/app/build/intermediates/pre-dexed/debug/support-annotations-21.0.2-1e9bba1e7979125665c442d859d2bfa58fa53060.jar /home/brett/AndroidStudioProjects/Perkisizer/app/build/intermediates/pre-dexed/debug/spotify-web-api-android-0.1.0-fca8ee2b37af4c8fd880358ca39c51176d2bdde5.jar /home/brett/AndroidStudioProjects/Perkisizer/app/build/intermediates/pre-dexed/debug/commons-codec-1.2-9cb6f7a99bfef71d74fdbf593c691f79fe52f88f.jar /home/brett/AndroidStudioProjects/Perkisizer/app/build/intermediates/pre-dexed/debug/ezmorph-1.0.6-63ab713bf9aaac80f51ada3eb44a5c4dae7cb827.jar /home/brett/AndroidStudioProjects/Perkisizer/app/build/intermediates/pre-dexed/debug/commons-beanutils-20030211.134440-ed02203e2b913d48dc67c294e8e9d2a005c0f248.jar /home/brett/AndroidStudioProjects/Perkisizer/app/build/intermediates/pre-dexed/debug/spotify-web-api-java-1.5.0-cb15a384dc7e748b33b8e9c9dbb19c095623d263.jar /home/brett/AndroidStudioProjects/Perkisizer/app/build/intermediates/pre-dexed/debug/gson-2.2.4-45eaac427fb9db50b682f13ce301f6dec56b70e7.jar /home/brett/AndroidStudioProjects/Perkisizer/app/build/intermediates/pre-dexed/debug/internal_impl-21.0.2-72d2b2b92c5ad40a9a6555b931f108f2f9be435d.jar /home/brett/AndroidStudioProjects/Perkisizer/app/build/intermediates/pre-dexed/debug/json-lib-2.4-jdk15-3429214c5d6c7f1ef41b701b00fd70d883bb4595.jar /home/brett/AndroidStudioProjects/Perkisizer/app/build/intermediates/pre-dexed/debug/commons-httpclient-3.1-e86b344f6d58191c5e89f3aeeb7ebe48114bd18d.jar /home/brett/AndroidStudioProjects/Perkisizer/app/build/intermediates/pre-dexed/debug/commons-lang-2.5-8b8d323f83fe48edf8dae63735500f986c1d4f01.jar /home/brett/AndroidStudioProjects/Perkisizer/app/build/intermediates/pre-dexed/debug/commons-collections-3.2.1-ce7dadf96ddf836e820202aa77f47d4c43e866df.jar /home/brett/AndroidStudioProjects/Perkisizer/app/build/intermediates/pre-dexed/debug/classes-32ad47a1c6cec698868b21d2fc53513df316dc96.jar /home/brett/AndroidStudioProjects/Perkisizer/app/build/intermediates/pre-dexed/debug/protobuf-java-2.5.0-3cf24fbc9e056b732d53f56ca77af34f35d2b15b.jar /home/brett/AndroidStudioProjects/Perkisizer/app/build/intermediates/pre-dexed/debug/classes-7671c176eaa1bf645a35219a5d65a175afb0d716.jar /home/brett/AndroidStudioProjects/Perkisizer/app/build/intermediates/pre-dexed/debug/guava-18.0-96a33973037064bdc79abeceda82313dd1c27f46.jar /home/brett/AndroidStudioProjects/Perkisizer/app/build/intermediates/pre-dexed/debug/classes-506ba11a5d837e5be104f25a842725b6d5d59fd7.jar
  Error Code:
    2
  Output:

UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: method ID not in [0, 0xffff]: 65536
    at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:501)
    at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:276)
    at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:490)
    at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:167)
    at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
    at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439)
    at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287)
    at com.android.dx.command.dexer.Main.run(Main.java:230)
    at com.android.dx.command.dexer.Main.main(Main.java:199)
    at com.android.dx.command.Main.main(Main.java:103)

Navigating pages

There's no easy/obvious/documented way to navigate through result pages. com.wrapper.spotify.models.Page has properties with a URL for previous and next page, but the members on the request to use them are private, and not accessible in any way. Could you provide an API and/or documentation on how to do that properly?

It should even be considered whether you want to bother the consumer of the API with paging. Normally (I guess!) the consumer simply wants to iterate through a result set, and doesn't want or need to know that the response from the Spotify server came in four pieces. Lazy loading might still be interesting, though.

Make the API extensible

The API lacks some functionality. It would be great if everything that's missing was added to the original project. But personally I, at the moment, don't want to bother with Maven and testing.

It is, however, very hard to add custom functionality to the API. The biggest problem is that you can't extend the Api class because it only has a private constructor. Also the method setDefaults would not be usable in a child class because it's private, maybe make it protected final.
The httpManager of AbstractRequest should also be accessible by child classes.

API attemps to override static method

The API requires the com.google.protobuf jar, but attempts to override a static method within it, which is not allowed by Java.

This error is thrown when attempting to run the example code for Synchronous Usage:
Exception in thread "main" java.lang.VerifyError: class com.wrapper.spotify.UtilProtos$Url overrides final method getUnknownFields.()Lcom/google/protobuf/UnknownFieldSet;

I have been unable to resolve this issue by using previous versions of the protobuf jar.

Thread-Safe Api

Is com.wrapper.spotify.Api intended to be thread-safe? If so, refreshAccessToken() needs to be modified to accept a String argument for the refresh token. Currently, if you call this method without setting a global refresh token, an assertion error occurs. I'm happy to make the change.

better error handling for getting a playlist with local/unavailable tracks

I noticed if a users playlist contains local tracks, or tracks that aren't available on spotify, a request to retrieve the playlist fails entirely. Once the loop retrieving each PlaylistTrack reaches the unavailable track, it throws a NPE and the entire request fails. It would be nice if the request succeeded, but unavailable tracks are omitted, or better yet, a new type of PlaylistTrack is created to handle these types of occurrences where some of the metadata (name, artist, or album) is missing, which causes the NPE.

How to get the authorization with show_dialog in it

I am following the tutorial in the README on how to authorize a user using the AuthorizationCodeGrant. However, this tutorial does not show any way of incorporating the show_dialog box into it. I understand that an AuthorizationURLRequest object needs to be used, but how do I take that and transform it into a URL I can send to my user?

Correct way of limiting track search to genre

Hello, this api is great! I'm just wondering if this is the correct way to limit track searches to a genre?

Char letter = "a";
String genre = "rap";
final TrackSearchRequest request = api.searchTracks(String.valueOf
(letter)).query("genre:" + genre).build();

Thank you very much

Issue with refreshing the access_token using the refresh_token

Hey Michael, first of all, this is an awesome library. I am trying to get a new access_token using the refreshToken api in this lib but keep on getting a 400 from spotify. Any clue on what I maybe doing wrong?

Api api = Api.builder()
        .build();

api.setAccessToken(accessToken);
api.setRefreshToken(refreshToken);
final SettableFuture<RefreshAccessTokenCredentials> refreshAccessTokenCredentialsFuture =
        api.refreshAccessToken().build().getAsync();

final SpotifyResponse[] spotifyResponse = {null};

Futures.addCallback(refreshAccessTokenCredentialsFuture, new FutureCallback<RefreshAccessTokenCredentials>() {
    @Override
    public void onSuccess(RefreshAccessTokenCredentials result) {
        spotifyResponse[0] = new SpotifyResponse(result.getAccessToken(), result.getExpiresIn());
    }

    @Override
    public void onFailure(Throwable throwable) {
        throwable.toString();
    }

});

but I constantly get a 400

How to set proxy host/port ?

Hello,

how can I set the proxy host/port when behind a proxy ?

Using httpClient I do:
HostConfiguration config = client.getHostConfiguration();
config.setProxy(PROXY_HOST, PROXY_PORT);

But the API does not give me access to the httpClient.

Some issues in including latest jar in project

I noticed a few issues while I was trying to include this library in a project. First was I downloaded the 1.4.1 jar but was seeing some class not found errors so I unzipped it and there were no java class files in the release.

I then dropped down to the 1.4.0 jar and had the same issue, I unzipped this and had to move around some of the binary directories to get it to work. So I moved spotify-web-api-java-1.4.0.jar(target/classes/) to the root level (so target/classes/com became com*) and zipped it back up and then it worked.

I also had to add your libraries dependencies into my project to get the project to run without a runtime exception. I think this would all be resolved if you hosted the jar on a maven artifactory.

Just so you know, I'm writing a scala 2.10 app with sbt version 0.13.2 and java 1.6.0_65

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.