Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
503 views
in Technique[技术] by (71.8m points)

facebook - Android single sign-on

I'm getting login failed invalid key error while using an updated version of Facebook. If I delete it - it's working fine..

What is the correct way of creating a hash key?

I know that there are a lot of questions and answers for single sign on in Android, but none helped me to implement single sign-on in Android.

My code:

public class Main extends Activity {
    Facebook facebook = new Facebook("XXXXXXXXXX");

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

        facebook.authorize(this, new DialogListener() {
            @Override
            public void onComplete(Bundle values) {}

            @Override
            public void onFacebookError(FacebookError error) {}

            @Override
            public void onError(DialogError e) {}

            @Override
            public void onCancel() {}
        });
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        facebook.authorizeCallback(requestCode, resultCode, data);
    }
}

Then I generated a hash key using the command

keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64

Also, I am having OpenSSL and given the location of OpenSSL upto openssl.exe..

After I hit Enter it is asking for a password and I gave android as the password. Then I got a key and filled in "My Application".

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The correct way to create a hash key

Please follow the following steps.

Here are the steps:

  1. Download OpenSSL from Google Code

  2. Extract it. Create a folder- OpenSSL in C:/ and copy the extracted code here.

  3. detect the debug.keystore file path. If you don't find it, then do a search in C:/ and use the path in the command in next step.

  4. detect your keytool.exe path and go to that dir/ in a command prompt and run this command (in one line):

    $ keytool -exportcert -alias androiddebugkey -keystore "C:Documents and SettingsAdministrator.androiddebug.keystore" | "C:OpenSSLinopenssl" sha1 -binary |"C:OpenSSLinopenssl" base64

  5. it will ask for a password. Put "android", that's all. You will get a key-hash.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...