【问题标题】:Is there a way to redeem the serverAuthCode in a standard HTTPS request?有没有办法在标准 HTTPS 请求中兑换 serverAuthCode?
【发布时间】:2020-08-08 08:48:37
【问题描述】:

https://developers.google.com/identity/sign-in/ios/offline-access 的文档展示了如何在 Swift 中获取 serverAuthCode。

这允许您自己的服务器将此代码兑换为 Oauth 访问令牌,并代表用户向 Google 发出 API 请求。

func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!) 
    let code = user.serverAuthCode
    // send it to the server
}

但是,该指南仅用 Java 或 Python 演示了该过程的服务器端部分。

是否可以仅使用 HTTPS 请求兑换此 serverAuthCode - 无需 Java/Python 库。如果是这样,如何做到这一点?

【问题讨论】:

    标签: ios swift oauth-2.0 google-oauth google-signin


    【解决方案1】:

    使用 Google 提供的 "OAuth 2.0 for Web Server" 指南似乎可以兑换 iOS 库生成的 serverAuthCode。

    标题为“第 5 步:交换授权码以获取刷新和访问令牌”的部分记录了简单的过程。

    尽管它要求redirect_uri,但这并不重要,因为它只需要在 Google 上注册并且实际上不会发生重定向。

    【讨论】:

      猜你喜欢
      • 2019-08-16
      • 1970-01-01
      • 1970-01-01
      • 2020-10-31
      • 2020-09-20
      • 2014-12-26
      • 1970-01-01
      • 2019-11-28
      • 1970-01-01
      相关资源
      最近更新 更多