Note that there are some explanatory texts on larger screens.

plurals
  1. POOAuthNotAuthorizedException using Signpost for Twitter on Android
    primarykey
    data
    text
    <p>I'm building a Twitter client on the Android platform</p> <p>With this code I continue to get an OAuthNotAuthorizedException, which according to the documentation means "the service provider rejected the consumer"</p> <p>This exception is happening on the retrieveAccessToken() method, so it has already received a request token from the retrieveRequestToken() method, meaning the callback is working.</p> <p>Am I not doing the OAuth setup correctly?</p> <pre><code>package com.android.bufftweet; imports ... public class Auth extends Activity { private final static String CONSUMER_KEY = "..."; private final static String CONSUMER_SECRET = "..."; private final static String CALLBACK_URL = "bufftweet://auth"; private OAuthProvider provider; private CommonsHttpOAuthConsumer consumer; private Bundle authBundle; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //init oauth consumer = new CommonsHttpOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET); consumer.setMessageSigner(new HmacSha1MessageSigner()); provider = new CommonsHttpOAuthProvider( "http://twitter.com/oauth/request_token", "http://twitter.com/oauth/access_token", "http://twitter.com/oauth/authorize"); String authUrl; try { authUrl = provider.retrieveRequestToken(consumer, CALLBACK_URL); startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(authUrl))); } catch (OAuthMessageSignerException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (OAuthNotAuthorizedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (OAuthExpectationFailedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (OAuthCommunicationException e) { // TODO Auto-generated catch block e.printStackTrace(); } } @Override public void onResume() { super.onResume(); authBundle = new Bundle(); Uri uri = this.getIntent().getData(); if (uri != null &amp;&amp; uri.toString().startsWith(CALLBACK_URL)) { String verifier = uri.getQueryParameter(oauth.signpost.OAuth.OAUTH_VERIFIER); // this will populate token and token_secret in consumer try { provider.retrieveAccessToken(consumer, verifier); } catch (OAuthMessageSignerException e) { e.printStackTrace(); } catch (OAuthNotAuthorizedException e) { e.printStackTrace(); } catch (OAuthExpectationFailedException e) { e.printStackTrace(); } catch (OAuthCommunicationException e) { e.printStackTrace(); } authBundle.putString("TOKEN",consumer.getToken()); authBundle.putString("TOKEN_SECRET", consumer.getTokenSecret()); authBundle.putString("CONSUMER_KEY", CONSUMER_KEY); authBundle.putString("CONSUMER_SECRET", CONSUMER_SECRET); Intent goToTweetHome = new Intent(Auth.this, TweetHome.class); goToTweetHome.putExtra("authBundle", authBundle); startActivity(goToTweetHome); } } } </code></pre> <p>Here's what my manifest looks like for reference</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.android.bufftweet" android:versionCode="1" android:versionName="1.0"&gt; &lt;uses-permission android:name="android.permission.INTERNET" /&gt; &lt;application android:icon="@drawable/ic_buff" android:label="@string/app_name"&gt; &lt;activity android:name=".BuffTweet" android:label="@string/app_name" android:windowSoftInputMode="stateVisible|adjustResize"&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;activity android:name=".Auth"&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.VIEW"&gt;&lt;/action&gt; &lt;category android:name="android.intent.category.DEFAULT"&gt;&lt;/category&gt; &lt;category android:name="android.intent.category.BROWSABLE"&gt;&lt;/category&gt; &lt;data android:scheme="bufftweet" android:host="auth"&gt;&lt;/data&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;activity android:name=".TweetHome"&gt; &lt;/activity&gt; &lt;/application&gt; &lt;uses-sdk android:minSdkVersion="7" /&gt; &lt;/manifest&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload