I have an RN Amplify project setup and working, the default for the Amplify config is "aws_appsync_authenticationType": "API_KEY",
. This is “public” mode. The app also supports Cognito user pool for users who want to create an account. Right now what I do is call Amplify.configure()
like so to switch to userPool
when a user creates an account:
Amplify.configure({
API: {
GraphQL: {
endpoint: amplifyconfig.aws_appsync_graphqlEndpoint,
region: amplifyconfig.aws_appsync_region,
defaultAuthMode: 'userPool',
apiKey: amplifyconfig.aws_appsync_apiKey
}
}
})
This works, however, when the user signs out or deletes their account and I call Amplify.configure()
and change the defaultAuthMode back to apiKey
, I get generic ‘identity’ errors calling the API.
Is there a better way to do this or an “official” way to support public vs. private users? I need to support both and obviously support sign out / delete account. The Amplify docs say that you can use an Unauth
Cognito role created by the project in place of the API_TOKEN but I could not get that working. TIA.