Signpost oauth + Discogs API

103 views
Skip to first unread message

Andreas Daskalopoulos

unread,
Dec 2, 2011, 6:16:08 AM12/2/11
to signpos...@googlegroups.com
Hi,

I am using signpost to authenticate with oauth for Discogs API [http://www.discogs.com/developers/oauth.html] on my android app. I was able to authenticate for 2 weeks now. The last 2 days I always "oauth.signpost.exception.OAuthExpectationFailedException: Request token or token secret not set in server reply. The service provider you use is probably buggy." when the following statement is executed:

String authUrl = provider.retrieveRequestToken(consumer, Constants.CALLBACK_URL);

Here is my code:

CommonsHttpOAuthConsumer consumer = new CommonsHttpOAuthConsumer(Constants.CONSUMER_KEY, Constants.CONSUMER_SECRET);
CommonsHttpOAuthProvider provider = new CommonsHttpOAuthProvider(Constants.REQUEST_TOKEN_ENDPOINT_URL, Constants.ACCESS_TOKEN_ENDPOINT_URL, Constants.AUTHORIZATION_WEBSITE_URL);
provider.setOAuth10a(true);
// Check if token and tokensecret are already stored at app preferences
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
String token = sharedPreferences.getString("token", null);
String tokenSecret = sharedPreferences.getString("token_secret", null);
   
if (token == null || tokenSecret == null) 
{
    Map<String, String> requestHeaders = provider.getRequestHeaders();
    requestHeaders.put("User-Agent", Constants.USER_AGENT);
    requestHeaders.put("Accept-Encoding", "gzip");
         
    try 
    {
        String authUrl = provider.retrieveRequestToken(consumer, Constants.CALLBACK_URL);
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(authUrl)));
    }
    catch (OAuthMessageSignerException e) 
    {
        e.printStackTrace();
    }
    catch (OAuthNotAuthorizedException e) 
    {
        e.printStackTrace();
    }
    catch (OAuthExpectationFailedException e) 
    {
        e.printStackTrace();
    }
    catch (OAuthCommunicationException e) 
    {
        e.printStackTrace();
    }
}
else
{
    showUI();
}

I checked the end point urls (I first thought that something changed there by Discogs team but this is not the issue). Can someone give me a hint? Thanks in advance.

Francisco Dalla Rosa Soares

unread,
Dec 2, 2011, 6:44:13 AM12/2/11
to signpos...@googlegroups.com
Hello,
Where's the place you're crashing?
Check if you really crashing when acquiring the tokens or if it is in
the ShowUI() which is probably where you're using signed requests).

If you're not crashing in the token acquisition, maybe your tokens
expired and you can't use the ones you've got stored. Most services do
that for security reasoens and then you have to go through the whole
process of acquiring the tokens again.

hope it helps

Francisco

> --
> You received this message because you are subscribed to the Google Groups
> "Signpost users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/signpost-users/-/Rxt27uDeBtEJ.
> To post to this group, send email to signpos...@googlegroups.com.
> To unsubscribe from this group, send email to
> signpost-user...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/signpost-users?hl=en.

Reply all
Reply to author
Forward
0 new messages