从 Swift 调用时,AWS Cognito 不会创建 Twitter/Digit 登录
AWS Cognito does not create Twitter/Digit login when called from Swift
所以我正在尝试使用 phone 号码让用户登录到我的应用程序。为此,我集成了来自 Twitter 的 Fabric Kit 和 AWS Cognito 的 Digit。我能够使用数字对用户进行身份验证并成功获取会话对象,并且可以提取用户 ID、phone 号码、authToken 和 authTokenSecret。但是,我无法 link 具有认知功能的数字身份验证用户。本质上 credentialsProvider.logins = ["www.digits.com": value]
(即使它执行)对配置的认知身份池没有任何影响。
这是我的 viewcontroller.swift
import UIKit
import DigitsKit
let credentialsProvider = AWSCognitoCredentialsProvider(
regionType: AWSRegionType.USEast1, identityPoolId: "IDENTITY_POOL_ID")
let defaultServiceConfiguration = AWSServiceConfiguration(
region: AWSRegionType.USEast1, credentialsProvider: credentialsProvider)
class ViewController: UIViewController {
@IBAction func login(sender: AnyObject) {
let digits = Digits.sharedInstance()
digits.authenticateWithCompletion { (session, error) in
if (session != nil) {
println("session user id is: " + session.userID)
println("session mobile no is: " + session.phoneNumber)
println("session token is: " + session.authToken)
println("session authtoken secret is: " + session.authToken)
var value = session.authToken + ";" + session.authTokenSecret
//THIS PART DOES NOT SET DIGIT LOGIN WITH COGNITO
credentialsProvider.logins = ["www.digits.com": value]
}
// Inspect session/error objects
}
}
@IBAction func logout(sender: AnyObject) {
}
override func viewDidLoad() {
super.viewDidLoad()
AWSServiceManager.defaultServiceManager().
defaultServiceConfiguration = defaultServiceConfiguration
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
我已经替换了正确的身份池 ID,并将消费者密钥和机密复制到亚马逊 Cognito 池中。我已经禁用了未经身份验证的 ID。我做错了什么?
AWSCognitoCredentialsProvider 延迟加载。简单地设置登录字典不足以使登录出现在控制台中。请尝试以下操作之一:
- 您可以使用凭证提供程序访问任何其他服务,例如使用 Amazon Cognito Sync 服务存储身份信息并同步到云。
- 您还可以强制凭证提供程序调用 Amazon Cognito Identity 服务。如果您没有缓存的身份 ID,
getIdentitId
方法将调用该服务来建立您的身份 ID。
- 如果您已经缓存了身份,则可以使用
refresh
方法强制使用登录字典的内容重新进行身份验证。
所以我正在尝试使用 phone 号码让用户登录到我的应用程序。为此,我集成了来自 Twitter 的 Fabric Kit 和 AWS Cognito 的 Digit。我能够使用数字对用户进行身份验证并成功获取会话对象,并且可以提取用户 ID、phone 号码、authToken 和 authTokenSecret。但是,我无法 link 具有认知功能的数字身份验证用户。本质上 credentialsProvider.logins = ["www.digits.com": value]
(即使它执行)对配置的认知身份池没有任何影响。
这是我的 viewcontroller.swift
import UIKit
import DigitsKit
let credentialsProvider = AWSCognitoCredentialsProvider(
regionType: AWSRegionType.USEast1, identityPoolId: "IDENTITY_POOL_ID")
let defaultServiceConfiguration = AWSServiceConfiguration(
region: AWSRegionType.USEast1, credentialsProvider: credentialsProvider)
class ViewController: UIViewController {
@IBAction func login(sender: AnyObject) {
let digits = Digits.sharedInstance()
digits.authenticateWithCompletion { (session, error) in
if (session != nil) {
println("session user id is: " + session.userID)
println("session mobile no is: " + session.phoneNumber)
println("session token is: " + session.authToken)
println("session authtoken secret is: " + session.authToken)
var value = session.authToken + ";" + session.authTokenSecret
//THIS PART DOES NOT SET DIGIT LOGIN WITH COGNITO
credentialsProvider.logins = ["www.digits.com": value]
}
// Inspect session/error objects
}
}
@IBAction func logout(sender: AnyObject) {
}
override func viewDidLoad() {
super.viewDidLoad()
AWSServiceManager.defaultServiceManager().
defaultServiceConfiguration = defaultServiceConfiguration
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
我已经替换了正确的身份池 ID,并将消费者密钥和机密复制到亚马逊 Cognito 池中。我已经禁用了未经身份验证的 ID。我做错了什么?
AWSCognitoCredentialsProvider 延迟加载。简单地设置登录字典不足以使登录出现在控制台中。请尝试以下操作之一:
- 您可以使用凭证提供程序访问任何其他服务,例如使用 Amazon Cognito Sync 服务存储身份信息并同步到云。
- 您还可以强制凭证提供程序调用 Amazon Cognito Identity 服务。如果您没有缓存的身份 ID,
getIdentitId
方法将调用该服务来建立您的身份 ID。 - 如果您已经缓存了身份,则可以使用
refresh
方法强制使用登录字典的内容重新进行身份验证。