Dooh. I thought I changed that.

Thanks. Luckily its a test pair.

Clay

On Jul 21, 12:13 pm, Taylor Singletary <taylorsinglet...@twitter.com>
wrote:
> Hi Clay,
>
> Just noticed that you have an API secret in this code sample you've
> provided -- you'll want to go to your application record and
> regenerate a new key/secret pair.
>
> As for the code itself -- I see you setting your consumer key and
> secret as constants near the top, but then in askOAuth you're using
> different values -- is this just a result of a bad paste?
>
> Taylor
>
> On Tue, Jul 20, 2010 at 11:18 PM, Clay Graham <claytan...@sightlyinc.com> 
> wrote:
> > Cant figure out if this is a problem with Twitter4J or the Twitter
> > API. I am trying to create an OAuth callback activity, started by a
> > RequestToken, but the Request Token request is failing. DOES ANYONE
> > KNOW IF GOOGLE HAS MADE THE TWITTER CLIENT AVAILABLE BY OPEN SOURCE
> > YET?
>
> > Twitter4J 2.1.2
> > Android Froyo 2.2
>
> > package com.sightlyinc.oauth.android;
>
> > import java.util.Date;
>
> > import twitter4j.Twitter;
> > import twitter4j.TwitterFactory;
> > import twitter4j.http.AccessToken;
> > import twitter4j.http.RequestToken;
> > import android.app.Activity;
> > import android.content.Intent;
> > import android.content.SharedPreferences;
> > import android.content.SharedPreferences.Editor;
> > import android.net.Uri;
> > import android.os.Bundle;
> > import android.preference.PreferenceManager;
> > import android.util.Log;
> > import android.view.View;
> > import android.view.View.OnClickListener;
> > import android.widget.Button;
> > import android.widget.EditText;
> > import android.widget.Toast;
>
> > public class SightlyOauthActivity extends Activity {
>
> >    private static final String TAG =
> > SightlyOauthActivity.class.getName();
>
> >    private Twitter twitter;
> >    private RequestToken requestToken;
> >    private SharedPreferences mSharedPreferences;
>
> >    private String CONSUMER_KEY =           "yfKRsmTgi8UT8eHoV5Khrw";
> >    private String CALLBACK_URL =           "sightlyoauth://oauth";
>
> >    private EditText tweetTextView;
> >    private Button buttonLogin;
>
> >        /** Called when the activity is first created. */
> >       �...@override
> >        public void onCreate(Bundle savedInstanceState) {
> >                super.onCreate(savedInstanceState);
> >                setContentView(R.layout.main);
>
> >                mSharedPreferences =
> >                        PreferenceManager.getDefaultSharedPreferences(
> >                                        getApplicationContext());
>
> >                tweetTextView =
> > (EditText)findViewById(R.id.TweetView);
> >        buttonLogin = (Button)findViewById(R.id.ButtonLogon);
> >        buttonLogin.setOnClickListener(new OnClickListener() {
> >                public void onClick(View v) {
> >                        askOAuth();
> >                }
> >        });
>
> >        }
>
> >        /**
> >         * Open the browser and asks the user to authorize the app.
> > Afterwards, we
> >         * redirect the user back here!
> >         */
> >        private void askOAuth() {
> >                try {
>
> >                        //setup properties, https was attempted and I
> > was advised to
> >                        //use HTTPS instead.
>
> > System.setProperty("twitter4j.http.useSSL","false");
>
> > System.setProperty("twitter4j.oauth.consumerKey","MYKEY");
>
> > System.setProperty("twitter4j.oauth.consumerSecret","MYSECRET");
>
> > System.setProperty("twitter4j.oauth.requestTokenURL","http://
> > api.twitter.com/oauth/request_token");
>
> > System.setProperty("twitter4j.oauth.accessTokenURL","http://
> > api.twitter.com/oauth/access_token");
>
> > System.setProperty("twitter4j.oauth.authorizationURL","http://
> > api.twitter.com/oauth/authorize");
>
> >                        //get the instance
> >                        Twitter twitter =
> >                                new TwitterFactory().getInstance();
>
> >                        //THIS EXCEPTS WITH PERMISSION DENIED
> >                        requestToken =
> > twitter.getOAuthRequestToken(CALLBACK_URL);
>
> >                        //set the request token info
> >                        Toast.makeText(this, "Please authorize this
> > app!",
> >                                        Toast.LENGTH_LONG).show();
>
> >                        this.startActivity(new
> > Intent(Intent.ACTION_VIEW, Uri
> >                                        
> > .parse(requestToken.getAuthenticationURL())));
>
> >                } catch (Exception e) {
> >                        Log.e(TAG, e.getMessage(),e);
> >                        Toast.makeText(this, e.getMessage(),
> > Toast.LENGTH_LONG).show();
> >                }
> >        }
>
> >        /**
> >         * As soon as the user successfully authorized the app, we are
> > notified
> >         * here. Now we need to get the verifier from the callback
> > URL,
> > retrieve
> >         * token and token_secret and feed them to twitter4j (as well
> > as
> > consumer
> >         * key and secret).
> >         */
> >       �...@override
> >        protected void onNewIntent(Intent intent) {
>
> >                super.onNewIntent(intent);
>
> >                Uri uri = intent.getData();
> >                if (uri != null &&
> > uri.toString().startsWith(CALLBACK_URL)) {
>
> >                        String verifier = uri
> >                                        .getQueryParameter("oauth_verifier");
>
> >                        try {
>
> >                                //this user has verified
> >                                AccessToken accessToken =
>
> > twitter.getOAuthAccessToken(requestToken, verifier);
>
> >                                //save the access token
> >                                Editor e = mSharedPreferences.edit();
> >                                e.putString("AccessToken.token",
> > accessToken.getToken());
> >                                e.putString("AccessToken.tokenSecret",
> > accessToken.getTokenSecret());
> >                                e.putString("AccessToken.screenName",
> > accessToken.getScreenName());
> >                                e.commit();
>
> >                                // initialize Twitter4J
> >                                twitter =
> >                                        new
> > TwitterFactory().getOAuthAuthorizedInstance(
> >                                                        CONSUMER_KEY,
> > CONSUMER_SECRET, accessToken);
>
> >                                // create a tweet
> >                                Date d = new
> > Date(System.currentTimeMillis());
> >                                String tweet = "#OAuth working! " +
> > d.toLocaleString();
>
> >                                // send the tweet
> >                                twitter.updateStatus(tweet);
>
> >                                // feedback for the user...
> >                                tweetTextView.setText(tweet);
> >                                Toast.makeText(this, tweet,
> > Toast.LENGTH_LONG).show();
>
> > buttonLogin.setVisibility(Button.GONE);
>
> >                        } catch (Exception e) {
> >                                Log.e(TAG, e.getMessage());
> >                                Toast.makeText(this, e.getMessage(),
> > Toast.LENGTH_LONG).show();
> >                        }
>
> >                }
> >        }
>
> > }
>
> > ====
>
> > 07-20 23:04:43.125: ERROR/
> > com.sightlyinc.oauth.android.SightlyOauthActivity(3368): Permission
> > denied
> > 07-20 23:04:43.125: ERROR/
> > com.sightlyinc.oauth.android.SightlyOauthActivity(3368):
> > TwitterException{statusCode=-1, retryAfter=0, rateLimitStatus=null}
> > 07-20 23:04:43.125: ERROR/
> > com.sightlyinc.oauth.android.SightlyOauthActivity(3368):     at
> > twitter4j.internal.http.HttpClientImpl.request(HttpClientImpl.java:
> > 316)
> > 07-20 23:04:43.125: ERROR/
> > com.sightlyinc.oauth.android.SightlyOauthActivity(3368):     at
> > twitter4j.internal.http.HttpClientWrapper.request(HttpClientWrapper.java:
> > 68)
> > 07-20 23:04:43.125: ERROR/
> > com.sightlyinc.oauth.android.SightlyOauthActivity(3368):     at
> > twitter4j.internal.http.HttpClientWrapper.post(HttpClientWrapper.java:
> > 99)
> > 07-20 23:04:43.125: ERROR/
> > com.sightlyinc.oauth.android.SightlyOauthActivity(3368):     at
> > twitter4j.http.OAuthAuthorization.getOAuthRequestToken(OAuthAuthorization.java:
> > 121)
> > 07-20 23:04:43.125: ERROR/
> > com.sightlyinc.oauth.android.SightlyOauthActivity(3368):     at
> > twitter4j.Twitter.getOAuthRequestToken(Twitter.java:1603)
> > 07-20 23:04:43.125: ERROR/
> > com.sightlyinc.oauth.android.SightlyOauthActivity(3368):     at
> > com.sightlyinc.oauth.android.SightlyOauthActivity.askOAuth(SightlyOauthActivity.java:
> > 95)
> > 07-20 23:04:43.125: ERROR/
> > com.sightlyinc.oauth.android.SightlyOauthActivity(3368):     at
> > com.sightlyinc.oauth.android.SightlyOauthActivity.access
> > $0(SightlyOauthActivity.java:64)
> > 07-20 23:04:43.125: ERROR/
> > com.sightlyinc.oauth.android.SightlyOauthActivity(3368):     at
> > com.sightlyinc.oauth.android.SightlyOauthActivity
> > $1.onClick(SightlyOauthActivity.java:54)
> > 07-20 23:04:43.125: ERROR/
> > com.sightlyinc.oauth.android.SightlyOauthActivity(3368):     at
> > android.view.View.performClick(View.java:2408)
> > 07-20 23:04:43.125: ERROR/
> > com.sightlyinc.oauth.android.SightlyOauthActivity(3368):     at
> > android.view.View$PerformClick.run(View.java:8816)
> > 07-20 23:04:43.125: ERROR/
> > com.sightlyinc.oauth.android.SightlyOauthActivity(3368):     at
>
> ...
>
> read more »

Reply via email to