So I'm trying to login user to my app using their phone number. For this I've integraed Digit from Twitter's Fabric Kit as well as AWS Cognito. I'm able to authenticate users using digit and successfully getting the session object and can extract the userid, phone number, authToken and the authTokenSecret. However I'm unable to link the digit authenticated user with cognito. Essentially credentialsProvider.logins = ["www.digits.com": value] never executes.
Here's my 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.
}
}
I've replaced the correct identity pool id and have copied the consumer key and secret to amazon cognito pool. I've disabled unauthenticated ids. What am I doing wrong?
Aucun commentaire:
Enregistrer un commentaire