2

I'm trying to implement Facebook Login with AWS Cognito. After receiving the access token from Facebook, I'm not able to update the credentials provider.

let token = FBSDKAccessToken.currentAccessToken().tokenString
credentialsProvider.logins = [AWSCognitoLoginProviderKey.Facebook.rawValue: token]

After this, if I print [AWSCognitoLoginProviderKey.Facebook.rawValue: token] I get the long string but if I print credentialsProvider.logins I get NIL.

As a result, my identity pool always shows the user as unauthenticated even after logging in with Facebook.

Any help would be appreciated. Thanks!!

bpiec
  • 1,561
  • 3
  • 23
  • 38

1 Answers1

1

Are you using the latest AWS iOS SDK? If yes, then credentialProvider.logins will always be NIL and will cause your app to create unauthenticated identities.

We are in process of updating our documentation for this but essentially this is what you need to do.

Use this constructor to create the credentials provider. The identityProviderManager here should be an implementation of AWSIdentityProviderManager Protocol and the logins method should return the dictionary mapping for your provider name to the token. The credentials provider will call this method every time it needs the identity provider token.

Chetan Mehta
  • 5,491
  • 1
  • 22
  • 21
  • Is there any documentation on how to create the AWSIdentityProviderManager and how to add the dictionary mapping to the logins for Swift? – Abhinav Sridharan May 11 '16 at 10:24
  • Hi sorry I've tried the construct as you said .. still not able to change unauthenticated user to authenticated `code let ip = AWSIdentityProviderManager?.init() ; ip?.logins().setValue(token, forKey: "graph.facebook.com") ` – Abhinav Sridharan May 12 '16 at 17:14
  • The logins are not supposed to be set in the managers. The logins method should return a valid dictionary of provered name as key and token as value. Check [this answer](http://stackoverflow.com/a/37146730/3204480) for more details. – Chetan Mehta May 14 '16 at 19:16