首页 > 解决方案 > (Unity) 无法在 android 上使用 google play 服务进行身份验证

问题描述

我在尝试在我的 android 游戏上进行身份验证时遇到问题,我使用 playfab + google play 服务在 google 上进行身份验证,但我什至无法到达我使用 google 帐户在 playfab 上进行身份验证的部分,Social.localUser.Authenticate永远不会成功并且它返回的消息在回调中是“身份验证取消”,我得到的唯一有用的日志消息是

[Play Games Plugin DLL] 应用程序正在暂停,这会断开 RTMP 客户端。离开房间。身份验证取消 [Play Games Plugin DLL] 调试:在游戏线程上调用用户回调

有时它会抛出

[Play 游戏插件 DLL] 启动 Auth 转换。操作:SIGN_IN 状态:ERROR_TIMEOUT

或者

[Play 游戏插件 DLL] 启动 Auth 转换。操作:SIGN_IN 状态:ERROR_NOT_AUTHORIZED

但仅此而已。最奇怪的是它打开了 Google Play Games 弹出窗口,它要求权限,我接受它,一切都按预期进行,但在应用程序中它永远不会成功。我已经在 Playfab 上注册了平台插件,在 google 开发者控制台上添加了一个链接的 web 应用程序,将客户端 oauth id 和 secret 复制到 playfab,配置了重定向的 uri 和端点链接(参考:https: //www.youtube .com/watch?v=FIse9VOk-FEhttps: //api.playfab.com/docs/tutorials/landing-players/sign-in-with-google )。但是这些都不起作用,我无法对其进行身份验证,无论它是否通过 Playstore 安装,我唯一没有尝试过的是将它作为 Playstore 上的 alpha 版本进行测试,目前正在进行内部测试.

[更新 1:] 我在清醒时使用的代码:

PlayGamesClientConfiguration config = new 
PlayGamesClientConfiguration.Builder()
        .AddOauthScope("profile")
        .WithInvitationDelegate(GoogleInvitation)
        .WithMatchDelegate(GoogleMatch)
        .RequestEmail()
        .RequestServerAuthCode(false)
        .RequestIdToken()
        .Build();
    PlayGamesPlatform.InitializeInstance(config);
    PlayGamesPlatform.DebugLogEnabled = true;
    PlayGamesPlatform.Activate();

我用来登录的代码:

Social.localUser.Authenticate((success, message) =>
    {
        Debug.Log("Authentication Message: " + message);

        if (success)
        {
            var serverAuthCode = PlayGamesPlatform.Instance.GetServerAuthCode();
            _AuthService.AuthTicket = serverAuthCode;
            _AuthService.Authenticate(Authtypes.Google);
        }
        else
        {

            Debug.Log("Failed  authenticating with google");
        }
    });

标签: androidunity3dgoogle-playgoogle-play-servicesgoogle-play-games

解决方案


你能提供一些代码吗?首先我认为你需要打电话

PlayGamesPlatform.Activate()

之后,所有社交功能都应该起作用。

此外,要实际测试 google play 服务,您需要将您的应用程序部署到 alfa/beta 测试或在 Play Market 中发布并从市场下载,否则它实际上不会工作。


推荐阅读