简体   繁体   English

Unity Play Games 无法进行身份验证

[英]Unity Play Games can't authenticate

I have a issue with play games services and unity.我在玩游戏服务和统一方面有问题。 I've done everything by the documentation.我已经按照文档完成了所有工作。 I'm a tester, testing is allowed and I've changed the sha1 in api console to the one used by the app.我是一名测试人员,允许进行测试,并且我已将 api 控制台中的 sha1 更改为应用程序使用的那个。 I'm using code from the docs and examples so here is a brief:我正在使用文档和示例中的代码,所以这里是一个简短的内容:

PlayGamesClientConfiguration conf = new PlayGamesClientConfiguration.Builder().Build();
PlayGamesPlatform.InitializeInstance(conf);
PlayGamesPlatform.DebugLogEnabled = true;
PlayGamesPlatform.Activate();

Debug.Log("Authenticating...");
Social.localUser.Authenticate((bool success) =>
{
    if (success)
    {
        Debug.Log("Welcome " + Social.localUser.userName);
    }
    else
    {
        Debug.Log("Authentication failed.");
    }
});

When I build the app in development mode the Play Games popup appears, starts loading and disappears and gives me a Authentication failed message.当我在开发模式下构建应用程序时,Play Games 弹出窗口出现,开始加载并消失,并给我一条身份验证失败的消息。 But when I build the app without the development mode nothing happens and I get the authentication failed message instantly.但是当我在没有开发模式的情况下构建应用程序时,没有任何反应,我立即收到身份验证失败的消息。 And yes I'm the correct sha1 key.是的,我是正确的 sha1 密钥。

Please help me请帮我

I did a number of things and finally got it to work.我做了很多事情,终于让它工作了。 I cannot be sure if they all contributed to solving this issue so here I will list what I did, from greatest to least of my guess of their relevance:我不确定他们是否都为解决这个问题做出了贡献,所以在这里我将列出我所做的,从最大到最小我对它们的相关性的猜测:

  1. Match the SHA-1 certificates.匹配 SHA-1 证书。 If you are using an app downloaded from Play Store use the "app signing certificate", else use the upload certificate.如果您使用的是从 Play 商店下载的应用程序,请使用“应用程序签名证书”,否则使用上传证书。 These are found in the Play Console under YourApp/Release Management/App Signing.这些可以在 Play 管理中心的 YourApp/Release Management/App Signing 下找到。 As a note, if you are building from Unity directly to your device, you should make sure that you are building with the same key used to upload to Google Play.请注意,如果您直接从 Unity 构建到您的设备,您应该确保您构建的密钥与用于上传到 Google Play 的密钥相同。 More info here更多信息在这里

  2. If you are using a custom config and are requesting things such .RequestServerAuthCode(false) , you must create an additional Web App .如果您使用自定义配置并请求诸如.RequestServerAuthCode(false)东西,则必须创建一个额外的Web App Go to your console project, and under create credentials choose OAuth client ID , and then select Web App .转到您的控制台项目,在create credentials选择OAuth client ID ,然后选择Web App

  3. If using internal testing, make sure to authorize accounts in the Play Console under Game Services/Your App/Testing.如果使用内部测试,请确保在 Play 管理中心的游戏服务/您的应用/测试下授权帐户。

  4. Try disabling Anti-Piracy in the Play Console under Game Services/Your App/Linked Apps/Your App.尝试在 Play 管理中心的游戏服务/您的应用/关联的应用/您的应用下禁用反盗版。 Only do this if you are testing app outside Google Play.仅当您在 Google Play 之外测试应用程序时才执行此操作。 I think if you are logging in using verified test accounts this doesn't matter.我认为如果您使用经过验证的测试帐户登录,这无关紧要。

Edit: Publishing Game Services is required even for testing.. at least that seemed to be the case for me to get it working.编辑:即使是测试也需要发布游戏服务......至少对我来说似乎是这样才能让它工作。

  1. Try clearing the cache of your App on your device, I ran into this problem again and this solved it for me.尝试清除设备上应用程序的缓存,我再次遇到了这个问题,这为我解决了。

I finally think I have got it fixed for good.. after nearly a month later.近一个月后,我终于认为我已经把它修复好了。 :o Hope this helps. :o 希望这会有所帮助。

Google Services can be published/unpublished separately from your app. Google 服务可以与您的应用分开发布/取消发布。 Check if they are correctly published doing the following:检查它们是否正确发布,请执行以下操作:

  1. Google Play Console谷歌游戏控制台
  2. Game services游戏服务
  3. Select your game选择你的游戏
  4. Publishing出版

Check if Game Services are published.检查游戏服务是否已发布。

在此处输入图片说明

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM