Search code examples
authenticationaws-amplify

Amplify Error: auth headless init is missing the following inputParams facebookAppIdUserPool, facebookAppSecretUserPool


G'day,

I had a working Amplify project. Well, it was all good until I run amplify add auth and push the changes to master. I was following the instruction here https://dev.to/dabit3/the-complete-guide-to-user-authentication-with-the-amplify-framework-2inh

Now I got the following error and my master is red :(

Can't find anything useful in the amplify documentation. I did try to run the headless_init_env_auth.sh script from this https://github.com/aws-amplify/amplify-cli/tree/master/packages/amplify-cli/sample-headless-scripts but it doesn't help.

This error doesn't seem to be documented anywhere.

2019-06-18T11:16:53.459Z [INFO]: Error: auth headless init is missing the following inputParams facebookAppIdUserPool, facebookAppSecretUserPool, googleAppIdUserPool, googleAppSecretUserPool
                                 at updateConfigOnEnvInit (/root/.nvm/versions/node/v8.12.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-category-auth/provider-utils/awscloudformation/index.js:287:15)
                                 at /root/.nvm/versions/node/v8.12.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-category-auth/index.js:201:28
                                 at /root/.nvm/versions/node/v8.12.0/lib/node_modules/@aws-amplify/cli/node_modules/promise-sequential/index.js:16:18
                                 at <anonymous>
                                 at process._tickDomainCallback (internal/process/next_tick.js:229:7)
2019-06-18T11:16:53.466Z [ERROR]: !!! Build failed
2019-06-18T11:16:53.466Z [ERROR]: !!! Non-Zero Exit Code detected```


Solution

  • Define facebookAppIdUserPool, facebookAppSecretUserPool, googleAppIdUserPool, googleAppSecretUserPool in AUTHCONFIG.

    #!/bin/bash
    set -e
    IFS='|'
    
    AUTHCONFIG="{\
    \"facebookAppId\":\"fbid1\",\
    \"googleClientId\":\"goog\",\
    \"facebookAppIdUserPool\":\"facebookAppId\",\
    \"facebookAppSecretUserPool\":\"facebookAppSecret\",\
    \"googleAppIdUserPool\":\"facebookAppSecret\",\
    \"googleAppSecretUserPool\":\"googleAppSecret\"\
    }"
    AWSCLOUDFORMATIONCONFIG="{\
    \"configLevel\":\"project\",\
    \"useProfile\":true,\
    \"profileName\":\"default\"\
    }"
    
    AMPLIFY="{\
    \"envName\":\"dev8\"\
    }"
    PROVIDERS="{\
    \"awscloudformation\":$AWSCLOUDFORMATIONCONFIG\
    }"
    CATEGORIES="{\
    \"auth\":$AUTHCONFIG\
    }"
    
    amplify init \
    --amplify $AMPLIFY \
    --providers $PROVIDERS \
    --categories $CATEGORIES \
    --yes
    

    or can use Amplify-CLI command

    amplify init \
    --amplify "{\"envName\":\"dev\"}" \
    --categories "{\"auth\":{\"googleAppIdUserPool\":\"googleAppId\",\"googleAppSecretUserPool\":\"googleAppSecret\"}}" \
    --yes