Amplify-js: ClientId is required in AWS configure but is not yet supported in Javascript SDK

Created on 11 Feb 2018  路  6Comments  路  Source: aws-amplify/amplify-js

AWS.Configure throws an error stating that

Both UserPoolId and ClientId are required.

When I go to my AWS cognito pool console to creat clientID and add it in my AWS.configure I then try to signUp a user and get a similiar issue:

https://stackoverflow.com/questions/37438879/resolve-unable-to-verify-secret-hash-for-client-in-amazon-cognito-userpools

Is it possible that there is some mismatch between what the configure module validates as mandatory and what the javascript SDK supports for the time being?

Most helpful comment

@jfrense, 'clientId' and 'client secret' are seperate things.

clientId must be sent from your javascript app, but will fail due to the client secret verification step, that is in your current userpool AppClient configuration.

You will need to re-create your userpool AppClient to remove the client secret verification step, that is causing your initial error.

  1. Delete your current userpool AppClient

  2. Recreate it, ensuring the 'generate client secret' is unchecked
    If this is done correctly after creation it should say '(no secret key)' in the App client secret field

  3. Include the clientId in your amplify config.

Your auth calls should work fine once you have completed these steps.

All 6 comments

I ran into this same issue. The solution is to uncheck "Generate client secret" when you are configuring your AWS cognito pool. This is required as app client secret is unsupported by Javascript clients.

@alchemiio I have done what you said in the AWS Cognito console but this still doesn't solve the original issue as the AWS amplify library requires that ClientId to be populated or else it throws an error on startup of react native application.

Amplify.configure({
  Auth: {
      identityPoolId: 'xxxxxxxxxxxxxxxxxx', 
      region: 'xxxxxxx', 
      userPoolId: 'xxxxxxxxx',
      userPoolWebClientId: 'xxxxxxxxxx' 
  }, Analytics: {
    appId: ' xxxxxxxxxxxxxxxxxxxx', 
    region: 'xxxxxxxxxxxx' 
}
});

^^ it seems that if userPoolId is defined in the AWS.configure object then userPoolWebClientId (ClientId) is required as well which I think shouldn't be the case since it is not supported in the javascript SDK.

@jfrense, 'clientId' and 'client secret' are seperate things.

clientId must be sent from your javascript app, but will fail due to the client secret verification step, that is in your current userpool AppClient configuration.

You will need to re-create your userpool AppClient to remove the client secret verification step, that is causing your initial error.

  1. Delete your current userpool AppClient

  2. Recreate it, ensuring the 'generate client secret' is unchecked
    If this is done correctly after creation it should say '(no secret key)' in the App client secret field

  3. Include the clientId in your amplify config.

Your auth calls should work fine once you have completed these steps.

Thanks for the detailed instructions. This worked!

@alchemiio @jfrense is userPoolWebClientId required for React Native projects or only userPoolId? Thanks!

@alchemiio @jfrense My bad, I can see now that userPoolWebClientId is the client id.

Was this page helpful?
0 / 5 - 0 ratings