I am trying to integrate Amazon Web Services into my app but frankly it has been a major challenge and it is extremely annoying.
I am using Amazon SDK (V2.1.0) for iOS and this is what I am trying to achieve:
I am trying to get Amazon Cognito working with the following code in my ViewController but I get nil for the variable cognitoId. My code is below:
AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:AWSRegionUSEast1
identityPoolId:@"us-east-1:XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX"];
AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1
credentialsProvider:credentialsProvider];
AWSServiceManager.defaultServiceManager.defaultServiceConfiguration = configuration;
NSString *cognitoId = credentialsProvider.identityId; //NULL
Based on everything I explained above, I have the following questions:
I appreciate anyone that can help. I am losing my mind over trying to get this to work the last couple of days.
Thanks!
The Cognito identity id isn't set by default. Are you making a call to getIdentityId or refresh with the provider? If not, I'd try that and see if you get a result.
As for your other questions, Cognito supports 'public providers' such as facebook, google, and amazon, as well as developer authenticated identities. For your suggested case with facebook, you could pretty easily use Cognito there. A blog post on Cognito roles and policies is available here.
Developer authenticated identities could be a valid (and more secure) way to implement your second use case. The workflow would require you to have a back end server, but you could only give access to the dynamo db table to that server. Users would log in, the app would send that data to your server, that server would validate and reply with credentials, and then the user could access your other AWS resources. A blog post describing the roles and policies in this context is available here and one giving more detail on the specifics and listing an end to end example is available here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With