【发布时间】:2017-03-08 06:27:53
【问题描述】:
我即将使用这个 cocoapod 构建一个使用 OAuth 2.0 的 iPad 应用程序:https://github.com/OAuthSwift/OAuthSwift。我正在浏览这个 firebase 教程 (https://firebase.google.com/docs/auth/ios/custom-auth),但是我有点困惑。
鉴于我有这个代码:
oauthswift = OAuth2Swift(
consumerKey: "********",
consumerSecret: "********",
authorizeUrl: "https://api.instagram.com/oauth/authorize",
responseType: "token"
)
let handle = oauthswift.authorize(
withCallbackURL: URL(string: "oauth-swift://oauth-callback/instagram")!,
scope: "likes+comments", state:"INSTAGRAM",
success: { credential, response, parameters in
print(credential.oauth_token)
FIRAuth.auth()?.signIn(withCustomToken: credential.oauth_token ?? "") { (user, error) in
// ...
}
},
failure: { error in
print(error.localizedDescription)
}
)
如果令牌是随机的并且对于每个设备都不同,firebase 将如何知道该令牌与哪个帐户相关联?我不知道如何将该令牌与帐户相关联。就像我使用用户名cool@example.com 和密码blah123 登录instagram 并且oauth_token 是123abc 如果123abc 是随机的,我怎么知道123abc 连接到我的firebase 帐户中的cool@example.com?
我觉得我误解了其中一个概念。
【问题讨论】:
标签: ios firebase oauth firebase-authentication