Android Facebook SSO登录失败:invalid_key:Android密钥不匹配 [英] Android Facebook SSO Login failed: invalid_key:Android key mismatch

查看:178
本文介绍了Android Facebook SSO登录失败:invalid_key:Android密钥不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我在Android应用程序中实现了Facebook SSO,并将帖子发送至FB墙.在整个开发过程中,无论是在模拟器上还是在我的手机上,所有时间都工作正常.我已经将我的debyg.keystore中的哈希值提供给FB应用程序了,一切都很好.现在,当我导出准备就绪的应用程序并对其进行签名时,我为发布密钥生成了一个新的哈希并将其放入应用程序设置中.安装后,它仍然可以在我的手机上正常工作,但不能在其他任何人的手机上正常工作.因此,我连接了另一部电话,并在尝试将消息发送到墙上时检查了日志.每次获得休闲响应:

So I've got a facebook SSO implemented in my Android app with sending a post to the FB wall. All the time throughout the development, both in emulator and on my phone, everything worked just fine. I've supplied the hash from my debyg.keystore to FB app, all fine. Now when I have exported my ready app and signed it I have produced a new hash for the release key and put it in the apps settings. When installed it still works perfectly on my phone but doesn't on anyone else's. So I've connected another phone and checked the logs while trying to send the message to the wall. Getting the fallowing response each time:

02-10 19:41:04.802:D/Facebook授权(26750):登录失败:invalid_key:Android密钥不匹配.您的密钥"pwrvr9ALAVF7yAL5pKmGWRwR8i0"与您在应用程序设置中指定的允许密钥不匹配.在 http://www.facebook.com/developers

02-10 19:41:04.802: D/Facebook-authorize(26750): Login failed: invalid_key:Android key mismatch. Your key "pwrvr9ALAVF7yAL5pKmGWRwR8i0" does not match the allowed keys specified in your application settings. Check your application settings at http://www.facebook.com/developers

我已经在手机和其他手机上重新安装了无数次,但仍然相同.这是导致授权然后发布到墙上或直接发布到墙上的代码段:

I've re-installed on my phone numerous times and on other phones but still the same. Here's the snippet of code that leads to either authorization and then posting to the wall or to posting straight to the wall :

 // Check if connected to the internet first
    if (connected())
    {


        //Get existing access_token if any

        mPrefs = getPreferences(MODE_PRIVATE);
        String access_token = mPrefs.getString("access_token", null);
        long expires = mPrefs.getLong("access_expires", 0);

        if(access_token != null) 
        {
            facebook.setAccessToken(access_token);
        }

        if(expires != 0) 
        {
            facebook.setAccessExpires(expires);
        }


        // Only call authorize if the access_token has expired.

        if(!facebook.isSessionValid()) 
        {
            facebookAuthorizeAndPost(msg);
        }
        else
        {
            posToFBWall(msg);
        }           

    }
    else
    {
        Toast.makeText(getBaseContext(), "There's been a problem connecting to Facebook. Please make sure you're connected to the internet and try again", Toast.LENGTH_SHORT).show();
    }   

这是进行实际授权的代码段,如果成功,则将其委托给postToFBWall()方法:

And here's the snippet that does the actual authorization and delegates to postToFBWall() method if successful:

private void facebookAuthorizeAndPost(final String msg)
{
    facebook.authorize(this, new String[] {}, new DialogListener() {
        @Override
        public void onComplete(Bundle values) {
            SharedPreferences.Editor editor = mPrefs.edit();
            editor.putString("access_token", facebook.getAccessToken());
            editor.putLong("access_expires", facebook.getAccessExpires());
            editor.commit();

            if (values.containsKey("access_token"))
            {
                posToFBWall(msg);
            }

        }

        @Override
        public void onFacebookError(FacebookError error) {}

        @Override
        public void onError(DialogError e) {}

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

}  

在这里做错了吗?更重要的是,Android密钥不匹配错误是什么意思,为什么会发生?任何人的想法,指针都表示赞赏.

Doing something wrong here? More to the point, what the Android key mismatch error mean, why does it occur? Anyone ideas, pointers appreciated.

推荐答案

基于该错误,我怀疑这是一个关键问题,并且生成错误.有时,密钥哈希指令根本不起作用.尽管遵循T的说明,但在获得正确的密钥哈希值时,我也遇到了类似的问题.

Based upon the error, I suspect that it is a key problem, and that it was generated incorrectly. Sometimes the keyhash instructions simply do not work. I have run into similar problems with getting the correct keyhash, despite following the instructions to the T.

也就是说,为了确保您拥有正确的密钥,我建议使用一个会告诉您正确密钥哈希值的android程序,例如:

That said, and just to be sure you have the correct key, I recommend using an android program that will tell you the correct keyhash, such as: http://www.easyfacebookandroidsdk.com/download/keyhash.zip

您需要做的就是导入项目,并使用与您的Facebook应用程序签名相同的密钥库对其进行签名.然后只需安装并运行它,它将显示密钥哈希.

All you need to do is import the project and sign it with the same keystore that you will sign your facebook application with. Then just install and run it, and it will display the keyhash.

编辑

您可能还需要再次检查您的密钥"pwrvr9ALAVF7yAL5pKmGWRwR8i0"是否实际上已列为开发人员页面上应用程序的密钥之一.

You may also want to double check that your key, "pwrvr9ALAVF7yAL5pKmGWRwR8i0" is actually listed as one of the keys for your app on the developer page.

这篇关于Android Facebook SSO登录失败:invalid_key:Android密钥不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆