400 Invalid_request 您无法登录此应用,因为它不符合 Google 为确保应用安全而制定的 OAuth 2.0 政策

     2023-03-16     237

关键词:

【中文标题】400 Invalid_request 您无法登录此应用,因为它不符合 Google 为确保应用安全而制定的 OAuth 2.0 政策【英文标题】:400 Invalid_request You can't sign in to this app because it doesn't comply with Google's OAuth 2.0 policy for keeping apps secure 【发布时间】:2021-10-20 12:53:03 【问题描述】:

当我尝试在我的 IOS 应用中向 Google 注册时遇到此错误。我得到了 REVERSED-CLIEND_ID,它看起来像这样:com.googleusercontent.apps..... 到目前为止,我可以打开 google 窗口并收到 400 错误。

AppDelegate:

class AppDelegate: UIResponder, UIApplicationDelegate 
    
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool 
        ApplicationDelegate.shared.application(application,didFinishLaunchingWithOptions: launchOptions)
        GIDSignIn.sharedInstance.restorePreviousSignIn  user, error in
            if error != nil || user == nil 
                // Show the app's signed-out state.
             else 
                // Show the app's signed-in state.
            
        
        return true
    
    
    func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool 
        ApplicationDelegate.shared.application(
            app,
            open: url,
            sourceApplication: options[UIApplication.OpenURLOptionsKey.sourceApplication] as? String,
            annotation: options[UIApplication.OpenURLOptionsKey.annotation]
        )
        var handled: Bool
        
        handled = GIDSignIn.sharedInstance.handle(url)
        if handled 
            return true
        
        
        // Handle other custom URL types.
        
        // If not handled by this app, return false.
        return false
    


视图控制器:

    let signInConfig = GIDConfiguration.init(clientID: "REVERSED_URL_THING")

  @IBAction func googleRegister(_ sender: UIButton) 
        GIDSignIn.sharedInstance.signIn(
            with: signInConfig,
            presenting: self
        )  user, error in
            guard error == nil else  return 
            guard let user = user else  return 

            // Your user is signed in!
        
    
    

【问题讨论】:

【参考方案1】:

如果有人遇到同样的问题,请在 Xcode 的 URL 类型中添加 iOS URL 方案不要使用反向 url,就像许多教程中所说的那样。使用 Google 提供的 CLIEND ID:

let signInConfig = GIDConfiguration.init(clientID: "CLIENT ID ")

【讨论】:

为啥我会收到 `invalid_request`:`no client authentication mechanism provided` 的 400 响应?

】为啥我会收到`invalid_request`:`noclientauthenticationmechanismprovided`的400响应?【英文标题】:WhyamIreceivinga400responseof`invalid_request`:`noclientauthenticationmechanismprovided`?为什么我会收到`invalid_request`:`noclientauthenticationmec 查看详情

Google OAuth 2.0 invalid_request,缺少方案

】GoogleOAuth2.0invalid_request,缺少方案【英文标题】:GoogleOAuth2.0invalid_request,MissingScheme【发布时间】:2017-06-1500:41:56【问题描述】:我无法在ios上授权GoogleOAuth,Safari总是这样说400这是一个错误。redirect_uri的参数值无效:缺少方案... 查看详情

400 多部分文件上传错误请求

...发了分段上传。通过改造我得到这个错误:"error":"code":"invalid_request","type":"invalid_request","messa 查看详情

使用 Apple JS 登录返回“invalid_request: Invalid redirect_uri”。

】使用AppleJS登录返回“invalid_request:Invalidredirect_uri”。【英文标题】:SignInWithAppleJSreturns\'invalid_request:Invalidredirect_uri.\'【发布时间】:2020-07-1903:53:53【问题描述】:我已开始将SignInWithApple集成到我的网站,但遇到了一些问题。... 查看详情

HttpException:400 无法验证您的数据提交

】HttpException:400无法验证您的数据提交【英文标题】:HttpException:400Unabletoverifyyourdatasubmission【发布时间】:2021-12-3000:55:36【问题描述】:我的日志文件充满了这些错误2021-11-1912:39:42[27.xxx.xxx.xxx][1958][gi96uqh6atadlbsg2ksjfltd9e][error][yii\\... 查看详情

http常见错误400/401/403/404/500及更多

...TTP错误400 400请求出错 由于语法格式有误,服务器无法理解此请求。不作修改,客户程序就无法重复此请求。 HTTP错误401 401.1未授权:登录失败 此错误表明传输给服务器的证书与登录服务器所需的证书不匹配。... 查看详情

nuxt auth : Google 提供商返回 invalid_request

】nuxtauth:Google提供商返回invalid_request【英文标题】:nuxtauth:Googleproviderreturninvalid_request【发布时间】:2021-04-2815:33:51【问题描述】:我尝试使用NuxtAuth模块设置google身份验证,但我从google收到以下错误:Error400:invalid_requestParameterno... 查看详情

http400-错误请求

...见错误HTTP错误400400请求出错由于语法格式有误,服务器无法理解此请求。不作修改,客户程序就无法重复此请求。HTTP错误401401.1未授权:登录失败此错误表明传输给服务器的证书与登录服务器所需的证书不匹配。请与Web服务器... 查看详情

http请求错误40040140240340440540640741241450

HTTP错误400?400请求出错?由于语法格式有误,服务器无法理解此请求。不作修改,客户程序就无法重复此请求。?HTTP错误401?401.1未授权:登录失败?此错误表明传输给服务器的证书与登录服务器所需的证书不匹配。?请与Web服务器的... 查看详情

服务器状态码

...TTP错误400 400请求出错 由于语法格式有误,服务器无法理解此请求。不作修改,客户程序就无法重复此请求。 HTTP错误401 401.1未授权:登录失败 此错误表明传输给服务器的证书与登录服务器所需的证书不匹配。... 查看详情

Gmail:无法让您登录(自动)

】Gmail:无法让您登录(自动)【英文标题】:Gmail:Couldn\'tsignyouin(automation)【发布时间】:2019-12-0716:48:38【问题描述】:尝试登录gmail时无法让您登录自动显示错误场景:我有一个自动化测试用例,它执行登录gmail并阅读收件箱中... 查看详情

400

...畸形的‘,即没有完全遵守HTTP协议。因此您的Web服务器无法理解和处理该请求。该错误几乎总是意味着客户端系统以及/或者您的Web服务器编程失败。解决400错误–一般方法在客户端或是Web服务器,或者两端都存在一个低层程... 查看详情

jmeter获取token并请求失败internalauthenticationfailed400

...服务器不理解请求的语法。 4、报错信息如下"error":"invalid_request","error_description":"Internalauthenticationfailed","error-code":"AUTH-1014" 如何解决?? 1、检查请求地址url是否正确,必须是能够获取token的url2、需要设置对应的contentt... 查看详情

aws cognito 用户池域 - Invalid_Request

】awscognito用户池域-Invalid_Request【英文标题】:awscognitouserpooldomain-Invalid_Request【发布时间】:2018-01-3112:40:16【问题描述】:我创建了一个用户池并使用应用程序客户端设置()设置域,以在cognito本身中托管注册和登录页面。当我尝... 查看详情

http请求错误400401402403404405406407412414500501502解析

...TTP错误400 400请求出错 由于语法格式有误,服务器无法理解此请求。不作修改,客户程序就无法重复此请求。 HTTP错误401 401.1未授权:登录失败 此错误表明传输给服务器的证书与登录服务器所需的证书不匹配。... 查看详情

http400错误的请求!解决追加悬赏!

...高手!HTTP错误400400请求出错由于语法格式有误,服务器无法理解此请求。不作修改,客户程序就无法重复此请求。HTTP错误401401.1未授权:登录失败此错误表明传输给服务器的证书与登录服务器所需的证书不匹配。请与Web服务器... 查看详情

您无法直接访问此页面 - HybridAuth 社交登录

】您无法直接访问此页面-HybridAuth社交登录【英文标题】:Youcannotaccessthispagedirectly-HybridAuthSocialLogin【发布时间】:2013-09-1010:01:55【问题描述】:我在我的网站中使用HybridAuth社交插件从facebook和其他网站登录,一切正常,但是当... 查看详情

Google Sign in API OAuth2 错误:youtube 范围内的“invalid_request”

】GoogleSigninAPIOAuth2错误:youtube范围内的“invalid_request”【英文标题】:GoogleSigninAPIOAuth2error:"invalid_request"withyoutubescope【发布时间】:2020-08-2623:35:19【问题描述】:当我选择用户帐户时,Google登录APIOAuth2可以正常工作。但... 查看详情