[英]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请检查以下步骤
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 文件。
Make sure you added the reverse client id from GoogleServicesInfo.plist id in Info.plist确保您在 Info.plist 中添加了来自 GoogleServicesInfo.plist id 的反向客户端 id
Delete the existing app from device and install again.从设备中删除现有应用程序并重新安装。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.