【发布时间】:2017-03-30 05:25:30
【问题描述】:
我正在使用OAuthSwift pod 进行 Google API 身份验证。在回调中,缺少刷新令牌。由于谷歌返回500 Server Error,当用户已经通过身份验证后尝试请求新令牌时,我想存储刷新令牌,并在用户下次登录时授权,并检索新令牌。
这是我的代码:
let callback = "\(Bundle.main.bundleIdentifier ?? ""):/oauth2Callback"
_ = ytOAuth2Swift?.authorize(
withCallbackURL: URL(string: callback)!,
scope: "https://www.googleapis.com/auth/youtube", state: state,
success: { credential, response, parameters in
print("YouTube Access_Token \(credential.oauthToken)")
print("YouTube efreshR_Token \(credential.oauthRefreshToken)")
},
failure: { error in
print("ERROR: \(error.localizedDescription)")
}
)
这是我们得到的回复!
根据 Google API 文档,这是应该进来的响应:
{
"access_token":"1/fFAGRNJru1FTz70BzhT3Zg",
"expires_in":3920,
"token_type":"Bearer",
"refresh_token":"1/xEoDL4iW3cxlI7yDbSRFYNG01kVKM2C-259HOF2aQbI"
}
我尝试使用嵌入式WebView 不走运:
[
【问题讨论】:
标签: ios oauth google-api youtube-data-api