ajdons / discogs4j

A java library that wraps the Discogs.com API v2.0
11 stars 6 forks source link

DiscogsClient.search #20

Closed lucblender closed 6 years ago

lucblender commented 6 years ago

I'm using your librarie and trying to use the search for DiscogsClient but only get {"message": "You must authenticate to access this resource."}. as answer. Here is the process I've to do this request:

String TOKEN = "my TOKEN";

String USER_AGENT = "my USER_AGENT ";
String CONSUMER_KEY = "my CONSUMER_KEY ";
String CONSUMER_SECRET = "my CONSUMER_SECRET ";
String CALLBACK_URL = "my CALLBACK_URL";

DiscogsClient client = new DiscogsClient(CONSUMER_KEY, CONSUMER_SECRET, USER_AGENT, LLBACK_URL);
        client.getRequestToken();

Map<String,String> temp= new HashMap<>();
            temp.put("type","artist");
            temp.put("per_page","1");
            temp.put("token",TOKEN);
            String answer = client.advancedSearch(formatArtistName,temp);

What is even weird is that your library print the requested URL for example: https://api.discogs.com/database/search?q=Glowsun&token=TOKEN&type=artist&per_page=1 And the link work in a normal browswer.

ajdons commented 6 years ago

The library is only a wrapper to help with your requests, it does not create responses. Any response you receive is from the Discogs API. In your case it looks like maybe you are making too many requests too quickly, click here for more information about Discogs API's rate limiting.

As for the request working in the browser, this is normal for a basic GET Request like this call. You can use the browser, or even better a tool like Postman to debug HTTP Requests to RESTful servers.

lucblender commented 6 years ago

I'm sorry I didn't copy past the correct error message... Totally my bad. The one that I had with this request is: {"message": "You must authenticate to access this resource."}. The rate limit was known to me, copy past mistake...

ajdons commented 6 years ago

In that case it looks like you the endpoint you are trying to access requires authentication. Here is the Discogs API page for authentication. This library helps with OAuth if you want to use it, as seen in the projet's README.