有没有办法在标准 HTTPS 请求中兑换 serverAuthCode?
Is there a way to redeem the serverAuthCode in a standard HTTPS request?
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 库。如果是这样,如何做到这一点?
使用 Google 提供的 "OAuth 2.0 for Web Server" 指南似乎可以兑换 iOS 库生成的 serverAuthCode
。
标题为 "Step 5: Exchange authorization code for refresh and access tokens" 的部分记录了简单的过程。
尽管它要求 redirect_uri
这并不重要,因为它只需要在 Google 上注册并且实际上不会发生重定向。
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 库。如果是这样,如何做到这一点?
使用 Google 提供的 "OAuth 2.0 for Web Server" 指南似乎可以兑换 iOS 库生成的 serverAuthCode
。
标题为 "Step 5: Exchange authorization code for refresh and access tokens" 的部分记录了简单的过程。
尽管它要求 redirect_uri
这并不重要,因为它只需要在 Google 上注册并且实际上不会发生重定向。