用于Unity的Google Play游戏登录用户返回“GetToken失败,状态代码为:NeedPermission”

时间:2017-06-20 19:01:57

标签: android authentication unity3d google-play-services google-play-games

我正在使用Unity的Google服务插件,可在此处找到:https://github.com/playgameservices/play-games-plugin-for-unity

我正在尝试添加基于Google的身份验证并获取服务器身份验证代码。

像这样初始化插件:

PlayGamesClientConfiguration playGamesConfiguration = new PlayGamesClientConfiguration.Builder()
            .RequestServerAuthCode(false)
            .AddOauthScope("profile")
            .AddOauthScope("email")
            .Build();
PlayGamesPlatform.InitializeInstance(playGamesConfiguration);
PlayGamesPlatform.DebugLogEnabled = Debug.isDebugBuild;
PlayGamesPlatform.Activate();

然后登录用户,呼叫:

UnityEngine.Social.localUser.Authenticate((success, errorString) => {
// Code here
}

当我运行游戏时,我会看到“正在连接到Google Play游戏”窗口,但应该登录用户并在屏幕顶​​部看到横幅。但我没有得到任何旗帜。以下是一些相关日志:

2295  2295 D GamesUnitySDK: Performing Android initialization of the GPG SDK
2295  2295 I Unity   : Building GPG services, implicitly attempts silent auth
2295  2694 I GamesNativeSDK: Auth operation started: SIGN IN
2295  2694 I GamesNativeSDK: Connecting to Google Play...
2295  2295 V GamesNativeSDK: Received Activity Resume Event.
1441  1452 W Auth    : [GetToken] GetToken failed with status code: NeedPermission
1383 17763 W Auth    : [GoogleAuthUtil] GoogleAuthUtil
2295  2295 V GamesNativeSDK: Play Games callback indicates connection failure.
2295  2694 I GamesNativeSDK: UI interaction required to connect to Google Play.
2295  2322 I Unity   : Success: False string: Authentication failed

“GetToken失败,状态代码:NeedPermission”行似乎是最重要的。我假设插件内部调用GetToken以满足我的请求,但我不知道它需要什么权限,或者用户是否应该提供此权限,或者这是否是仪表板中的开发人员权限。

任何帮助都将不胜感激。

1 个答案:

答案 0 :(得分:0)

作为后续,事实证明Google Play游戏控制台设置不正确。那里有一些问题,我认为最重要的是未向测试用户授予API访问权限。由于我无权访问控制台,因此无法亲自验证设置。

作为对Google的额外评论,错误代码中提供的信息越多,越容易找出配置错误的内容。许多项目使用分散的团队,实际上可以与开发控制台进行交互的人员可能更多是生产者,而技术人员则更少。能够准确告知他们如何解决错误消息,从而节省了大量调试时间。

相关问题