OAuth and Facebook

Put your problem here if it does not fit any of the other categories.

OAuth and Facebook

Postby jsucamel » Fri May 28, 2010 10:10 pm

Hey guys,

I'm trying to allow my app to push a Status Update to Facebook. I gave the new Android Facebook SDK a shot, but it's in Alpha and I don't want to make my app reliant on something that's bound to change pretty quickly. As a result, I'm falling back on plain raw OAuth requests.

Here's what I have:

Code: Select all
String FACEBOOK_URL = "https://graph.facebook.com/oauth/authorize?client_id="+APP_ID+"&display=touch&redirect_uri=http://sample-app.com/";
          try {
             this.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(FACEBOOK_URL)));
          } catch (Exception e){
             Log.e("Error", e.getMessage());
          }


and my AndroidManifest.xml file looks like:

Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example.app"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".ExampleApp"
                  android:label="@string/app_name"
                  android:launchMode="singleInstance">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
         <intent-filter> 
                   <action android:name="android.intent.action.VIEW"></action> 
               <category android:name="android.intent.category.DEFAULT"></category> 
               <category android:name="android.intent.category.BROWSABLE"></category>
               <data android:scheme="http" android:host="sample-app.com"></data> 
            </intent-filter> 
        </activity>

    </application>
    <uses-sdk android:minSdkVersion="6" />
   <uses-permission android:name="android.permission.INTERNET" />
</manifest>


Here's what's happening: I activate the intent, and it takes me to the proper Facebook sign in page. I sign in, and it redirects me to the proper callback URL (sample-app.com). However, Facebook doesn't recognize Android internal URLs (like myapp://sample). Instead, it returns on http://sample.com. I don't really have a problem with that, but what's happening is that a dialog comes up that says "Complete action using..." and then gives the user a choice between the Browser and my app.

I don't want the user to be able to choose -- I need it to return me to the app! If I choose my app, the app continues working perfectly. I just can't figure out how to make it go back to the App automatically, instead of asking whether to use the browser or not.

Is there a better way of doing this? I've tried various Facebook wrappers, and I'd much prefer to stick with a simple OAuth thing that I know I can control 100%, but if anyone has any suggestions I'd love to hear them.

Help?

Regards,
Camel
jsucamel
Freshman
Freshman
 
Posts: 2
Joined: Mon Dec 22, 2008 6:44 pm

Top

Re: OAuth and Facebook

Postby jonneymendoza » Tue Jun 01, 2010 3:04 pm

Hi did you managed to figure out a solution to your problem? i followed this guide here http://donpark.org/blog/2009/01/24/andr ... side-oauth and it diddnt work.

The browser would not close and go back to my app. i am using LinkedIn by the way, not FB but it should be the same way you are doing it as they both use OAuth
jonneymendoza
Developer
Developer
 
Posts: 36
Joined: Fri Sep 04, 2009 10:30 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 14 guests