ios - 如何使用后端集成设置 iOS Google 登录?

标签 ios go cross-platform google-oauth

我正在尝试按照以下位置的说明进行操作:https://developers.google.com/identity/sign-in/ios/offline-access .每当我发送 token 时,我都会得到:“redirect_uri_mismatch”。

我在另一个问题中读到,客户端 ID 需要稍等片刻。不是这种情况。后端 ID 自 8 月以来一直处于事件状态。该网络应用程序运行良好。服务器 json 将“redirect_uris”设置为“postmessage”。

这看起来与问题非常相似:Cross-platform Google OAuth Signin: redirect_uri mismatch但我的场景是使用 iOS 和 Go。

如果我按照 https://developers.google.com/identity/protocols/CrossClientAuth 的建议添加范围“audience:server:client_id:”我收到“无效范围”错误。

最佳答案

我找到了路。

首先,忘掉“audience:server:client_id:”。

    let signin = GIDSignIn.sharedInstance()
    signin.clientID = "XXXX-YYYY.apps.googleusercontent.com"
    signin.serverClientID = "XXXX-ZZZZ.apps.googleusercontent.com"
    signin.scopes.append("https://www.googleapis.com/auth/plus.me")
    signin.delegate = self

其次,redirect_uris 无关紧要。

最后,您唯一需要注意的是 serverAuthCode 只会出现一次。因此,如果您支持注销,请务必 GIDSignIn.sharedInstance().signOut

关于ios - 如何使用后端集成设置 iOS Google 登录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40252570/

相关文章:

约束和自动布局背后的 IOS 算法

css - 无论操作系统如何,Firefox 和 Safari 的行为是否相似?

c++ - 您最喜欢用 C/C++ 访问多个不同数据库(MySQL、Oracle...)的跨平台解决方案是什么?

dictionary - 如何在Golang中使用与 map 中的键相同的数据来区分两种自定义结构类型?

c++ - 有人试过在 Windows 上编译 Go 吗?它现在似乎支持生成 PE 格式的二进制文件

google-app-engine - go get 失败,返回 "no buildable Go source files found in github.com/..."

database-design - 协助使用数据库架构(独立于平台)

ios - 快速自定义右转

iOS 10 如何使用 UNUserNotificationCenter 查看待处理通知列表?

objective-c - 将委托(delegate)分配给我的 PieChartView 时发送到实例的无法识别的选择器