After reading through tons of documentation and a lot of trial and error, I was able to actually create a lambda (api gateway) driven backend for developer authentication in my aws mobile hub application.
- I have subclassed AWSCognitoCredentialsProviderHelper to create my developer identity provider
- Implemented: getIdentityId, token and logins in the custom class
instantiation:
devIdentityProvider = DeveloperIdentityProvider(
regionType: AWSRegionType.USEast1,
identityPoolId: getIdentityPoolFromPlist()!,
useEnhancedFlow: true,
providerName: "login.myapp",
identityProviderManager: AWSIdentityManager.defaultIdentityManager())
let credentialsProvider = AWSCognitoCredentialsProvider(
regionType: AWSRegionType.USEast1,
unauthRoleArn: nil,
authRoleArn: nil,
identityProvider: devIdentityProvider!)
let configuration = AWSServiceConfiguration(
region: AWSRegionType.USEast1,
credentialsProvider: credentialsProvider)
AWSServiceManager.defaultServiceManager().defaultServiceConfiguration = configuration
then I do a credentialsProvider.credentials() to get authenticated credentials for the token/identityId returned from my backend. All this seems to work and I get back AccessKey, SessionKey etc. So it seems to work fine.
In the continue block though, if I try to call a AWSDynamoDB or syncdata I get:
Unauthenticated access is not supported for this identity pool.
What might I be missing to make sure that AWS services in the mobile hub app, receive the updated credentials? Also, How do I involve AWSIdentityManager in this? Because it seems like AWSIdentityManager.defaultIdentityManger never gets userName etc. from my custom Identity Provider. Any help will be really appreciated.