Hi folks,

I'm writing an Android app for Brightkite using the oAuth API and I've
hit a bit a a stopping point.  I've had a look at the example for the
Desktop application and I can't work out what it's doing with
overwriting the accessor.  I've pasted the first part of the
authorisation below, which invokes a webview to allow the app to be
authed with the request token:

package org.ifies.brightroid;

import java.net.URL;

import net.oauth.OAuthAccessor;
import net.oauth.OAuthConsumer;
import net.oauth.OAuthServiceProvider;
import net.oauth.client.OAuthClient;
import net.oauth.client.httpclient4.HttpClient4;
import android.app.Activity;
import android.app.AlertDialog;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.util.Log;
import android.content.DialogInterface;
import android.content.Intent;

public class AppSettings extends Activity {
        private static final String OAUTH_REQUEST = "http://brightkite.com/
oauth/request_token";
        private static final String OAUTH_AUTHORIZE = "http://brightkite.com/
oauth/authorize";
        private static final String OAUTH_ACCESS = "http://brightkite.com/
oauth/access_token";
        private static final String BRIGHTKITE_AUTHORIZE_URL = "http://
brightkite.com/oauth/authorize?oauth_token=";
        private static String CONSUMER_KEY = "";
        private static String CONSUMER_SECRET = "";

        public OAuthClient httpClient;
        public OAuthAccessor accessor;
        public OAuthServiceProvider provider;
        public OAuthConsumer consumer;

        private BrightRoid br_app;

        private static Button button_auth;
        private static Button button_back_from_settings;

        @Override
        public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setNoTitle();
        setContentView(R.layout.app_settings);

        br_app = new BrightRoid();

        button_auth = (Button) findViewById(R.id.button_auth);
        button_auth.setOnClickListener(new View.OnClickListener(){
                @Override
                public void onClick(View v) {
                        try {
                                Log.i("Application", "We get to try very 
hard!");
                                doLoginAuth();
                        } catch (Exception e) {
                                Log.e("Auth Error", e.getMessage().toString());
                        }
                }
        });
        button_back_from_settings = (Button) findViewById
(R.id.button_back_from_settings);
        button_back_from_settings.setOnClickListener(new
View.OnClickListener(){
                        @Override
                        public void onClick(View v) {
                                finish();
                        }
        });
        }

        public void setNoTitle() {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
    }

    public void doLoginAuth() throws Exception {
        Log.i("Application", "We get into the function");
        provider = new OAuthServiceProvider(
                        OAUTH_REQUEST,
                        OAUTH_AUTHORIZE,
                        OAUTH_ACCESS);
        consumer = new OAuthConsumer(null // callback URL
                , CONSUMER_KEY // consumer key
                , CONSUMER_SECRET // consumer secret
                , provider);
        accessor = new OAuthAccessor(consumer);
        Log.i("Application", "oAuth stuff 1 done");
        httpClient = new OAuthClient(new HttpClient4() {

                        @SuppressWarnings("unused")
                        public HttpClient4 getHttpClient(URL server) {
                                return new HttpClient4();
                        }
                });

        try {
                Log.i("Application", "Were going to try again");
                        httpClient.getRequestToken(accessor);
                        Log.i("Application", "Http Got token");
                        // manually set the access token to the request 
token...not sure
                        // why
                        accessor.accessToken = accessor.requestToken;
                        Log.i("Application", "Set Token");
                        //br_app.app_database.addRow("String", "accessToken",
accessor.accessToken.toString());
                        //Log.i("Application", "DB Dave Done");
                        if (accessor.accessToken != "") {
                                Log.i("Application", "we have a token");
                                Intent auth_intent = new 
Intent(AppSettings.this,
oAuthRequest.class);
                                auth_intent.putExtra("BRIGHTKITE_AUTHORIZE_URL",
BRIGHTKITE_AUTHORIZE_URL);
                                auth_intent.putExtra("request_token",
accessor.requestToken.toString());
                                
auth_intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
                                Log.i("Application", "We get to invoking the 
activity");
                                AppSettings.this.startActivity(auth_intent);
                        }

                } catch (Exception e) {
                        Log.e("oAuth Error", e.getMessage().toString());
                }
    }

}


After that, and the user closes the window, I want to pass this on to
a new intent that exchange the key for the auth key, but the only
example I can find is here:  http://awalkingcity.com/blog/?p=13

However, in this example, it uses the deprecated invoke method.  Can
anyone help me out with getting this part sorted out?

Thanks,
Tane
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"OAuth" group.
To post to this group, send email to oauth@googlegroups.com
To unsubscribe from this group, send email to oauth+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/oauth?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to