我已经在我的应用程序的登录部分工作了一段时间。我正在尝试使用 ASW Mobile Hub 来解决这个问题。我找到了一种让它与我需要的不同提供商一起工作的方法:我自己的用户池、FB 和 Google。
问题是我一直在这里和整个 AWS 文档中搜索,试图找到获取用户数据(用户名和一些其他用户数据,如图片、电子邮件等)的方法。如果我直接使用 FBSDK(使用 FBSDKGraphRequest),我可以得到它,但如果用户选择登录我的 cognito-user-pool,我不知道该怎么做。我也看不到用户成功使用的提供程序。
我可以找到其他一些方法来获得它,但使用旧的 SDK o 直接 Cognito 调用,最初并不是我需要的。这是我用来显示登录窗口的代码:
override func viewDidLoad() {
super.viewDidLoad()
if !AWSSignInManager.sharedInstance().isLoggedIn {
presentAuthUIViewController()
}
}
func presentAuthUIViewController() {
let config = AWSAuthUIConfiguration()
config.enableUserPoolsUI = true
config.addSignInButtonView(class: AWSFacebookSignInButton.self)
config.addSignInButtonView(class: AWSGoogleSignInButton.self)
AWSAuthUIViewController.presentViewController(
with: self.navigationController!,
configuration: config, completionHandler: { (provider:
AWSSignInProvider, error: Error?) in
if error == nil {
// SignIn succeeded.
} else {
// end user faced error while loggin in, take any
required action here.
}
})
}
那么问题来了,一旦登录成功,如何获取相关的用户信息?