简体   繁体   English

颤振:PlatformException(sign_in_failed,org.openid.appauth.oauth_token,invalid_audience:受众不是有效的客户 ID。,null)

[英]flutter: PlatformException(sign_in_failed, org.openid.appauth.oauth_token, invalid_audience: Audience is not a valid client ID., null)

I am trying to add google sign in (without firebase) to my flutter app.我正在尝试将 google 登录(没有 firebase)添加到我的颤振应用程序中。

I have created google cloud project, created oauth consent screen and credentials.我创建了谷歌云项目,创建了 oauth 同意屏幕和凭据。 I am using我在用

  google_sign_in: ^5.3.2
  googleapis: ^9.0.0

Also i had to add我也必须添加

 <dict>
    <key>CFBundleTypeRole</key>
    <string>Editor</string>
    <key>CFBundleURLSchemes</key>
    <array>
        <string>com.googleusercontent.apps.618518636914-abc</string>
    </array>
</dict>

to allow ios to launch browser for google sign in, I am able to enter email and password, after that the app permission screen (This app wants to access your google drive... ) screen briefly appears and disappears, and i can see this error in terminal为了让 ios 启动浏览器进行谷歌登录,我可以输入电子邮件和密码,然后应用权限屏幕(此应用想要访问您的谷歌驱动器...)屏幕短暂出现并消失,我可以看到这个终端错误

   [VERBOSE-2:ui_dart_state.cc(209)] Unhandled Exception: PlatformException(sign_in_failed, org.openid.appauth.oauth_token, invalid_audience: Audience is not a valid client ID., null)
#0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:607:7)
#1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:177:18)
<asynchronous suspension>
#2      MethodChannel.invokeMapMethod (package:flutter/src/services/platform_channel.dart:377:43)
<asynchronous suspension>
#3      GoogleSignIn._callMethod (package:google_sign_in/google_sign_in.dart:247:30)
<asynchronous suspension>
#4      GoogleSignIn.signIn.isCanceled (package:google_sign_in/google_sign_in.dart:377:5)
<asynchronous suspension>

This is the code used for login这是用于登录的代码

class GoogleSignInApi {
  static final _googleSignIn = GoogleSignIn(
      hostedDomain: "",
      clientId:
          "618518636914-abd.apps.googleusercontent.com");

  static Future<GoogleSignInAccount?> login() => _googleSignIn.signIn();
}

i referred this post Google Api and android Oauth INVALID_AUDIENCE error , but my client id is correct and it's of type iOS client only (in google oauth credentials) and Google Sign in fails on iOS 13 GM this is for pure iOS project, it might be still relevant.我提到了这篇文章Google Api 和 android Oauth INVALID_AUDIENCE 错误,但我的客户端 ID 是正确的,并且它的类型仅为 iOS 客户端(在 google oauth 凭据中)并且Google 在 iOS 13 GM 上登录失败这是针对纯 iOS 项目的,它可能是仍然相关。 But i am not able to figure out the version of iOS's AppAuth which is used by flutter's google_sign_in .但我无法弄清楚颤振的google_sign_in使用的 iOS AppAuth的版本。

Any help will be highly appreciated, thank you.任何帮助将不胜感激,谢谢。

Please check the following steps请检查以下步骤

  1. Open xcode and select runner, then right click on the runner and select add files to runner.打开 xcode 并选择 runner,然后右键单击 runner 并选择 add files to runner。 In the pop up window make sure that copy files is checked.在弹出窗口中确保选中复制文件。 Browse and select the Google services plist file.浏览并选择 Google 服务 plist 文件。

  2. Make sure you added the reverse client id from GoogleServicesInfo.plist id in Info.plist确保您在 Info.plist 中添加了来自 GoogleServicesInfo.plist id 的反向客户端 id

  3. Delete the existing app from device and install again.从设备中删除现有应用程序并重新安装。

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

相关问题 iOS 本机登录使用 Apple 令牌返回捆绑 ID 作为受众而不是服务 ID - iOS Native Sign In With Apple token return bundle ID as audience instead of Service ID 验证失败:invalid_token(受众群体为项目“”,但应为项目“”) - Getting Authentication failed: invalid_token (audience was project ' ' but should have been project ' ') 使用AppAuth for iOS和Azure AD的观众声明不正确 - Incorrect audience claim using AppAuth for iOS and Azure AD Firebase自定义身份验证令牌不同的受众 - Firebase custom auth issue token different audience flutter 中的 Facebook 登录错误:访问令牌错误:{“code”:190,“message”:“Invalid OAuth 访问令牌。”}], null) - Facebook login error in flutter : Bad access token: {“code”:190,“message”:“Invalid OAuth access token.”} ], null) 为什么custom_audience_third_party_id总是为零 - Why is custom_audience_third_party_id always nil 提取OAuth2访问令牌时出错-invalid_grant。 但有效 - Error fetching OAuth2 access token - invalid_grant. BUT it is VALID 如何捕获 Flutter Google 登录 PlatformException? - How do I catch Flutter Google sign-in PlatformException? Facebook受众群体网络评论iOS - Facebook Audience network review iOS iOS应用程序分发给有限的受众 - iOS application distribution to limited audience
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM