2011년 8월 28일 일요일

안드로이드 페이스북 SSO 연동 오류 해결방법

구글링을 통해 해결한 방법을 소개 합니다. 아래의 onActivityResult에 추가한 것이 유효한 방법 입니다.

Hopefully you have downloaded Facebook SDK and played with some basic examples. [If not, please go through http://developers.facebook.com/docs/guides/mobile/ ]
Now to enable SSO for your android app, you need to download following libraries
  • Open SSO [http://code.google.com/p/openssl-for-windows/downloads/list] and extract in c:\dev\
  • Now locate you key tool under JavaSDK\bin folder [To simply your headache, you can add these both in your path, in case if you are not not adding in path , hereafter give complete path to executable.]
  •    For debug mode , first open a command prompt and executes following command
keytool -exportcert -alias androiddebugkey -keystore c:\Users\<your windows default user> \.android\debug.keystore | openssl sha1 -binary | open ssl base64
Enter keystore password:  android  
<For debug mode this is the password you have to use , for release  mode , point key store to you actual key store and enter strong password>
  • Now open developer.facebook.com and go to you app.
  • Edit application open mobile section in setting. 
  • Under android enter this hash and save app. It will take few minutes to propagate changes on Facebook server. 
  • Once done go to command prompt and install your application.
adb install <path to your application apk file>
  • Hopefully your application is working now able to use Facebook SSO . In case, if it’s not, check which step you missed.
  • But you wont be able to get access token back, for that you have to override onActivityResult method in calling activity as following.

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
if(fb != null) fb.authorizeCallback(requestCode, resultCode, data);
}

[Here fb is Facebook instance, change it as per your Facebook Instance name]
Once you do above, you will be able to use Facebook Single sign on.

원본 :
http://www.zubha-labs.com/facebook-single-sign-on-for-android

댓글 없음:

댓글 쓰기