Android的功能NEW SSO登录失败:invalid_key:Android的关键不匹配不匹配、关键、功能、Android

2023-09-07 09:40:23 作者:无心贪良夜

所以,我已经得到了实现在我的Andr​​oid应用程序与发送邮寄到FB墙上的Facebook的单点登录。所有的时间在整个开发,无论是在模拟器和我的手机上,一切工作就好了。我从我的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

我已经重新安装在我的手机多次和其他手机,但仍然是相同的。下面是code中的片段,导致无论是授权,然后张贴到墙上或直接张贴在墙上:

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钥匙不匹配的错误意思是,为什么会出现这种问题?任何人的想法,指针AP preciated。

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

推荐答案

基于错误,我怀疑这是一个关键的问题,而且它产生的不正确。有时,keyhash说明根本不工作。我遇到了类似的问题,得到正确的keyhash,尽管按照指示到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.

这是说,只是要确保你有正确的密钥,我建议使用一个机器人程序,会告诉你正确的keyhash,如:的 http://www.easyfacebookandroidsdk.com/download/keyhash.zip

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应用程序签名。然后,只需安装并运行它,它会显示keyhash。

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.