简体   繁体   English

Google Login 不适用于 AWS Mobile Hub 生成的 Android 应用程序

[英]Google Login does not work with AWS Mobile Hub generated Android app

I have generated an app with AWS Mobile Hub.我使用 AWS Mobile Hub 生成了一个应用程序。 Google Login works fine in the start.谷歌登录在开始时工作正常。 But if I give the exactly same codes to the other developer it gives the error below.但是,如果我向其他开发人员提供完全相同的代码,则会出现以下错误。 Or if I refactor the package name Google Login does not work anymore even with my own computer.或者,如果我重构包名称,即使使用我自己的计算机,Google 登录也不再起作用。 (With iOS google-login works fine). (使用 iOS google-login 可以正常工作)。 I have tried to follow all the instructions but no help.我已尝试按照所有说明进行操作,但没有任何帮助。 I have also changed the package name for OAuth 2.0 client ID for android (console.developers.google.com).我还为 android (console.developers.google.com) 更改了 OAuth 2.0 客户端 ID 的包名称。

Error message: Google failed.错误信息:谷歌失败。 Unknown (Service: google-sign-in; Status Code: 503; Error code: 503; Request ID: google-sign-in) packageName Vs applicationID Android AWS Mobile Sign-in with未知(服务:google-sign-in;状态代码:503;错误代码:503;请求 ID:google-sign-in) packageName Vs applicationID Android AWS Mobile Sign-in with

Here is one solution that did not work with me: http://mobiledevelopmenttips.blogspot.fi/2016/02/packagename-vs-applicationid-android.html?showComment=1461311778234#c2030693740616382564这是一种对我不起作用的解决方案: http : //mobiledevelopmenttips.blogspot.fi/2016/02/packagename-vs-applicationid-android.html?showComment=1461311778234#c2030693740616382564

Here's a couple things to check.这里有几件事要检查。

  1. Make sure any other developer are registered as test accounts.确保任何其他开发人员都注册为测试帐户。 https://developers.google.com/games/services/console/testpub#enabling_accounts_for_testing https://developers.google.com/games/services/console/testpub#enabling_accounts_for_testing

  2. Make sure you're both running the app in debug mode or you're signing it with the same certificate.确保你们都在调试模式下运行应用程序,或者使用相同的证书对其进行签名。 https://developer.android.com/tools/publishing/app-signing.html#studio https://developer.android.com/tools/publishing/app-signing.html#studio

  3. If you change the package name, make sure you make that change in the build.gradle file, not just in the AndroidManifest.xml file.如果更改包名称,请确保在 build.gradle 文件中进行更改,而不仅仅是在 AndroidManifest.xml 文件中。

Hopefully, if you check those issues, you'll get things going.希望如果你检查这些问题,你会得到进展。 Otherwise, I would recommend looking through Google's troubleshooting documentation.否则,我建议您查看 Google 的故障排除文档。

Jukka,尤卡,

Assuming that no other Application ID or package names have changed from your project code, this error is expected with Google Sign-in when using your debug.keystore and sharing project code.假设您的项目代码中没有其他应用程序 ID 或包名称发生更改,那么在使用您的 debug.keystore 和共享项目代码时,Google Sign-in 会出现此错误。

This error occurs when the Signing-certificate fingerprint (SHA-1) of the Client ID for Android from your console.developers.google.com project DOES NOT MATCH the fingerprint of the developers that signed the app.当来自您的 console.developers.google.com 项目的Android 客户端 ID签名证书指纹 (SHA-1)与签署应用程序的开发人员的指纹不匹配时,就会发生此错误。 To reproduce your error, modify the Android Client ID SHA-1 fingerprint value in the google dev console and then attempt to sign-in from your current environment.要重现您的错误,请在 google dev 控制台中修改 Android 客户端 ID SHA-1 指纹值,然后尝试从您当前的环境登录。 I would expect a similar error:我预计会出现类似的错误:

com.amazon.mysampleapp E/SignInActivity:User Sign-in failed for Google
: Unknown (Service: google-sign-in; Status Code: 503; Error Code: 503;
Request ID: google-sign-in)

在此处输入图片说明

Issue : Each development environment has a unique debug keystore used to sign an apk.问题:每个开发环境都有一个唯一的调试密钥库,用于对 apk 进行签名。 Google Sign-in restricts access to only those apps signed by a known SHA-1 signing-certificate you provided when creating the Android Client ID. Google Sign-in 将访问权限限制为仅由您在创建 Android 客户端 ID 时提供的已知 SHA-1 签名证书签名的应用程序。 The other developer has a different fingerprint, signs the apk and fails because his/her fingerprint is not associated with an Android Client ID.另一个开发人员使用不同的指纹,签署 apk 并失败,因为他/她的指纹与 Android 客户端 ID 无关。

Solution : Create a new Android Client ID associated with your Google Developer Console project that contains the other developers fingerprint (you can have multiple Google Client IDs within a single Google Console Project).解决方案:创建一个与您的 Google Developer Console 项目相关联的新 Android 客户端 ID,其中包含其他开发者指纹(您可以在一个 Google 控制台项目中拥有多个 Google 客户端 ID)。 Note: When enabling Google Sign-in feature in your Mobile Hub project, Mobile Hub actually creates an OpenID Connect provider (accounts.google.com) in IAM on your behalf.注意:在您的 Mobile Hub 项目中启用 Google 登录功能时,Mobile Hub 实际上会代表您在 IAM 中创建一个 OpenID Connect 提供程序 (accounts.google.com)。 Within the provider, Mobile Hub adds the Android Client Id you provided as an "Audience" to the provider.在提供程序中,Mobile Hub 将您作为“受众”提供的 Android 客户端 ID 添加到提供程序。 Still with me?还和我在一起吗?

The Android Client ID you provided is not in your generated sample code and is only used to identify the signed app attempting to make API calls directly to Google.您提供的 Android 客户端 ID 不在您生成的示例代码中,仅用于识别尝试直接向 Google 发出 API 调用的已签名应用。

So, to recap the solution:所以,回顾一下解决方案:

  1. Create a new Android Client ID (within Google Dev Console) with the other developers fingerprint following the steps outlined in the side panel help documentation within the Mobile Hub console.按照 Mobile Hub 控制台中侧面板帮助文档中列出的步骤,使用其他开发人员指纹创建新的 Android 客户端 ID(在 Google Dev Console 中)。

  2. Log into AWS IAM Console, select "Identity Providers" > "accounts.google.com" and ADD your newly generated Android Client ID as a new "Audience".登录 AWS IAM 控制台,选择“身份提供商”>“accounts.google.com”并将您新生成的 Android 客户端 ID 添加为新的“受众”。 If you forget/ignore this step, you'll get status code 400 NotAuthorizedException Incorrect token audience from Cognito when attempting to sign-in.如果您忘记/忽略此步骤,您将在尝试登录时从 Cognito 收到状态代码 400 NotAuthorizedException Incorrect token Audience。

This will not be an issue with a production app.这不会是生产应用程序的问题。 When you prepare to release your app on the app store(s), follow Google's suggested steps to generate a NEW final client ID for your production app and then provide that client ID to IAM as an "Audience".当您准备在应用商店发布您的应用时,请按照 Google 建议的步骤为您的生产应用生成新的最终客户端 ID,然后将该客户端 ID 作为“受众”提供给 IAM。 Once you sign the apk and release it, all users have the same signed APK and will be able to authenticate via Google Sign-in.一旦您签署并发布 apk,所有用户都拥有相同的已签名 APK,并且可以通过 Google 登录进行身份验证。 https://support.google.com/cloud/answer/6158849?hl=en#android https://support.google.com/cloud/answer/6158849?hl=en#android

Finally it started to work when I did these four things:当我做了这四件事时,它终于开始工作了:

  1. Created new AWS Mobile Hub project创建新的 AWS Mobile Hub 项目

  2. Created new Google Credentials project and used new ids for Mobile Hub project创建了新的 Google Credentials 项目并为 Mobile Hub 项目使用了新的 ID

  3. Refactored package name in our real application to a new name (I don't mean refactoring from com.mysampleapp package name which had been refactored earlier but we had to decide new package path for our internal use)将我们真实应用程序中的包名重构为一个新名称(我的意思不是从 com.mysampleapp 包名重构,之前已经重构过,但我们必须决定新的包路径供我们内部使用)

    • eg like this com.company.myapp -> com.company.myapp2例如像这样 com.company.myapp -> com.company.myapp2
  4. I put back Guest Login functionality in AWS Mobile Hub我在 AWS Mobile Hub 中恢复了访客登录功能

    • This was the last step to make it work for me but maybe this is not crucial for others who might have similar problems.这是使其对我有用的最后一步,但对于可能有类似问题的其他人来说,这可能并不重要。 We have had different options should we allow guest login during the project so that's why it was important to us.如果我们在项目期间允许访客登录,我们有不同的选择,这就是为什么它对我们很重要。

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

相关问题 谷歌登录不适用于使用电容器生成的离子 android 移动应用程序 - 抛出异常为 10 - google sign in does not work on ionic android mobile application generated using capacitor - exception thrown as 10 我的 android 应用程序在模拟器上运行并在 android 设备上运行,但在移动设备上无法登录页面 - my android app run on emulator and run on android devices but does not login page work in mobile devices Android中的AWS Mobile Hub自定义身份验证 - AWS Mobile Hub Custom authentication in android meteor 移动应用程序不适用于 android 9 和 10 - meteor mobile app does not work on android 9 and 10 将AWS Mobile Hub与我的Android项目集成时遇到问题 - Having trouble integrating AWS Mobile Hub with my Android project 适用于Android应用的Google登录 - Google Login For Android App 如果applicationId更改,Mobile Hub示例应用程序Google登录将被取消 - Mobile Hub Sample App Google Sign -in canceled if applicationId changes Android / Java / Appium - 向下滑动(滚动)不起作用[移动应用] - Android / Java / Appium - Swipe (Scroll) Down does not work [Mobile App] 将消息从Android移动应用发送到Azure IoT中心 - Send message from Android mobile app to Azure IoT Hub 如果在模拟器上安装了Facebook应用,则无法登录到Facebook-Android 4.3 - Login to facebook does not work if facebook app is installed on emulator - Android 4.3
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM