amplify-cli icon indicating copy to clipboard operation
amplify-cli copied to clipboard

Amplify pull failed: auth headless is missing the following inputParams googleAppIdUserPool, googleAppSecretUserPool

Open JackPenney opened this issue 5 years ago • 15 comments

Before opening, please confirm:

  • [X] I have installed the latest version of the Amplify CLI (see above), and confirmed that the issue still persists.
  • [X] I have searched for duplicate or closed issues.
  • [X] I have read the guide for submitting bug reports.
  • [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.

How did you install the Amplify CLI?

npm

If applicable, what version of Node.js are you using?

12.18.4

Amplify CLI Version

7.5.4

What operating system are you using?

Windows

Amplify Categories

auth

Amplify Commands

pull

Describe the bug

While working in my dev environment I ran amplify pull -y which gave me the error auth headless is missing the following inputParams googleAppIdUserPool, googleAppSecretUserPool I've made no pending changes and ran a pull to make sure everything is up to date

Running amplify pull --appId ***** --envName localdev works but if i try to do a standard amplify pull afterwards the error comes back

Tried running amplify update auth without changing any of my OAuth settings just in case the update triggers a fix for newer versions but no luck

There's an old issue for this here: https://github.com/aws-amplify/amplify-js/issues/7194 and I already have the environment variables AMPLIFY_GOOGLE_CLIENT_ID and AMPLIFY_GOOGLE_CLIENT_SECRET setup which was the suggested solution

I'm not on the latest version of amplify, been told to stick to 7.5.4 as there's issues in the later versions that are also having an impact

Expected behavior

I expect it to pull and apply the changes from my environment

Reproduction steps

run amplify pull

GraphQL schema(s)

No response

Log output

Local changes detected.
Pulling changes from the cloud will override your local changes.
√ Successfully pulled backend environment localdev from the cloud.
× There was an error initializing your environment.
auth headless is missing the following inputParams googleAppIdUserPool, googleAppSecretUserPool
Error: auth headless is missing the following inputParams googleAppIdUserPool, googleAppSecretUserPool
    at updateConfigOnEnvInit (C:\Users\jspen\AppData\Roaming\npm\node_modules\@aws-amplify\cli\node_modules\@aws-amplify\amplify-category-auth\src\provider-utils\awscloudformation\index.js:136:15)
    at C:\Users\jspen\AppData\Roaming\npm\node_modules\@aws-amplify\cli\node_modules\@aws-amplify\amplify-category-auth\src\index.js:349:28
    at C:\Users\jspen\AppData\Roaming\npm\node_modules\@aws-amplify\cli\node_modules\promise-sequential\index.js:16:18
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)

Additional information

No response

JackPenney avatar Dec 01 '21 21:12 JackPenney

Hey @JackPenney :wave: thanks for raising this! On the latest version of the CLI (7.6.2) I was able to reproduce using the following steps:

  1. create a new project with amplify init -y
  2. amplify add auth > Default Social... > add Google credentials
  3. amplify push -y
  4. create a new git repo, connect to git
  5. add hosting > Continuous Integration... using Amplify Console
  6. push to git repo, allow console to rebuild
  7. Observe error in Console, mitigate by adding environment variables noted in the report
  8. create a new resource locally (to get some change locally), amplify add function
  9. attempt to run amplify pull -y
  10. Observe error
> amplify pull -y

Pre-pull status:

    Current Environment: dev
    
┌──────────┬────────────────┬───────────┬───────────────────┐
│ Category │ Resource name  │ Operation │ Provider plugin   │
├──────────┼────────────────┼───────────┼───────────────────┤
│ Function │ 917651aca61e   │ Create    │ awscloudformation │
├──────────┼────────────────┼───────────┼───────────────────┤
│ Auth     │ 9176a66315aa   │ No Change │ awscloudformation │
├──────────┼────────────────┼───────────┼───────────────────┤
│ Hosting  │ amplifyhosting │ No Change │                   │
└──────────┴────────────────┴───────────┴───────────────────┘

Local changes detected.
Pulling changes from the cloud will override your local changes.
⠹ Fetching updates to backend environment: dev from the cloud.⠋ Building resource auth/9176a66315a✔ Successfully pulled backend environment dev from the cloud.
✖ There was an error initializing your environment.
auth headless is missing the following inputParams googleAppIdUserPool, googleAppSecretUserPool
Error: auth headless is missing the following inputParams googleAppIdUserPool, googleAppSecretUserPool
    at updateConfigOnEnvInit (/Users/josef/.fnm/node-versions/v16.13.0/installation/pnpm-global/5/node_modules/.pnpm/@[email protected]/node_modules/@aws-amplify/amplify-category-auth/src/provider-utils/awscloudformation/index.js:136:15)
    at /Users/josef/.fnm/node-versions/v16.13.0/installation/pnpm-global/5/node_modules/.pnpm/@[email protected]/node_modules/@aws-amplify/amplify-category-auth/src/index.js:349:28
    at /Users/josef/.fnm/node-versions/v16.13.0/installation/pnpm-global/5/node_modules/.pnpm/[email protected]/node_modules/promise-sequential/index.js:16:18

josefaidt avatar Dec 06 '21 21:12 josefaidt

If any of you could provide your appId and region where this is happening that would be great.

ganipcanot avatar Dec 10 '21 16:12 ganipcanot

@JackPenney Can you confirm if this workflow is working with the latest version?

ammarkarachi avatar Dec 10 '21 19:12 ammarkarachi

Hey @ganipcanot my appId is: d1y0lxfx9s7bhz The region is: eu-west-1

@ammarkarachi I've updated to CLI v7.6.3 and ran amplify pull and got the following error in the console:

Local changes detected.
Pulling changes from the cloud will override your local changes.
√ Successfully pulled backend environment localdev from the cloud.
× There was an error initializing your environment.
auth headless is missing the following inputParams googleAppIdUserPool, googleAppSecretUserPool
Error: auth headless is missing the following inputParams googleAppIdUserPool, googleAppSecretUserPool
    at updateConfigOnEnvInit (C:\Users\jspen\AppData\Roaming\npm\node_modules\@aws-amplify\cli\node_modules\@aws-amplify\amplify-category-auth\src\provider-utils\awscloudformation\index.js:136:15)
    at C:\Users\jspen\AppData\Roaming\npm\node_modules\@aws-amplify\cli\node_modules\@aws-amplify\amplify-category-auth\src\index.js:349:28
    at C:\Users\jspen\AppData\Roaming\npm\node_modules\@aws-amplify\cli\node_modules\promise-sequential\index.js:16:18
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)

JackPenney avatar Dec 13 '21 19:12 JackPenney

Is the bug resolved? I am facing with this issue

giangchau92 avatar Sep 26 '22 05:09 giangchau92

@josefaidt Can we please get an escalation of this issue? This issue seems to still be occurring and is preventing us from having automatic pulling of configurations via amplify pull for CI/CD deployments. I am on the latest version of the cli at the time of this posting (10.5.1).

ignitum-ryan avatar Dec 04 '22 01:12 ignitum-ryan

I'm also being me with limited success using amplify pull in Github Actions.

sh pull.sh                                                                                              1 ✘  5s  
Amplify AppID found: d3xxxxxxxxxxju. Amplify App name is: exampleApp
Backend environment sandbox found in Amplify Console app: exampleApp
✔ Successfully pulled backend environment sandbox from the cloud.
✖ There was an error initializing your environment.
🛑 Could not initialize categories for 'sandbox': auth headless is missing the following inputParams userPoolId, webClientId, nativeClientId, identityPoolId

Resolution: Review the error message and stack trace for additional information.
Learn more at: https://docs.amplify.aws/cli/project/troubleshooting/

pull.sh

#!/bin/bash
set -e
IFS='|'

REACTCONFIG="{\
\"SourceDir\":\"src\",\
\"DistributionDir\":\"build\",\
\"BuildCommand\":\"npm run-script build\",\
\"StartCommand\":\"npm run-script start\"\
}"
AWSCLOUDFORMATIONCONFIG="{\
\"configLevel\":\"project\",\
\"useProfile\":true,\
\"profileName\":\"default\"\
}"
AMPLIFY="{\
\"projectName\":\"headlessProjectName\",\
\"appId\":\"d3xxxxxxxxxxju\",\
\"envName\":\"sandbox\",\
\"defaultEditor\":\"code\"\
}"
FRONTEND="{\
\"frontend\":\"javascript\",\
\"framework\":\"react\",\
\"config\":$REACTCONFIG\
}"
PROVIDERS="{\
\"awscloudformation\":$AWSCLOUDFORMATIONCONFIG\
}"

amplify pull \
--amplify $AMPLIFY \
--frontend $FRONTEND \
--providers $PROVIDERS \
--yes

As mentioned, no issues when it is not headless:

amplify pull --appId d3xxxxxxxxxxju --envName sandbox                                                   1 ✘  5s  
? Select the authentication method you want to use: AWS profile

For more information on AWS Profiles, see:
https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html

? Please choose the profile you want to use default
Amplify AppID found: d3ihuduewsr9ju. Amplify App name is: exampleApp
Backend environment sandbox found in Amplify Console app: exampleApp
? Choose your default editor: Visual Studio Code
? Choose the type of app that you're building javascript
Please tell us about your project
? What javascript framework are you using react
? Source Directory Path:  src
? Distribution Directory Path: build
? Build Command:  npm run-script build
? Start Command: npm run-script start
? Do you plan on modifying this backend? No

✅ Added backend environment config object to your project.
Run 'amplify pull' to sync future upstream changes.

tim-g-provectusalgae avatar Dec 05 '22 02:12 tim-g-provectusalgae

The only way that I have been able to get around this is to export the configuration of each environment inside a folder in my project:

-- amplifyconfiguration-dev.dart -- amplifyconfiguration-test.dart

Then, the build process picks up and replaces the amplifyconfiguration file in the root directory of the project before proceeding with the build.

While this does function, it is a HUGE limitation because if any configuration details get added/removed/changed in the amplifyconfiguration, it requires the developer to recreate the configuration file and drop it in the correct location before deploying a specific version.

I wanted people to have an, albeit ugly and not something I would recommend, workaround versus deployments of different Amplify environments simply not working. Especially when using CI/CD.

ignitum-ryan avatar Feb 03 '23 17:02 ignitum-ryan

Facing the same issue with amplify-cli 10.7.1.

hanna-becker avatar Feb 08 '23 13:02 hanna-becker

Interesting callout @hanna-becker . I have never thought about specific resources impacting this. We also have a Lambda layer in our infrastructure, but have from the beginning (and this process has never worked)

^FYI @danielleadams -> In case you need a starting point.

ignitum-ryan avatar Feb 08 '23 18:02 ignitum-ryan

Actually I edited my comment because I remembered we're still on 7.3.1 in our prod env without a lambda layer. I tested there and it produced the same error, so I suppose it's unrelated.

hanna-becker avatar Feb 08 '23 18:02 hanna-becker

I've found the solution for this problem. Based on:

https://docs.amplify.aws/cli/usage/headless/#--categories

You can add configurations for the different categories on the init script. Here's the script suggested in the docs:

#!/bin/bash
set -e
IFS='|'

REACTCONFIG="{\
\"SourceDir\":\"src\",\
\"DistributionDir\":\"build\",\
\"BuildCommand\":\"npm run-script build\",\
\"StartCommand\":\"npm run-script start\"\
}"
AWSCLOUDFORMATIONCONFIG="{\
\"configLevel\":\"project\",\
\"useProfile\":false,\
\"profileName\":\"default\",\
\"accessKeyId\":\"headlessaccesskeyid\",\
\"secretAccessKey\":\"headlesssecrectaccesskey\",\
\"region\":\"us-east-1\"\
}"
AMPLIFY="{\
\"projectName\":\"headlessProjectName\",\
\"envName\":\"myenvname\",\
\"defaultEditor\":\"code\"\
}"
FRONTEND="{\
\"frontend\":\"javascript\",\
\"framework\":\"react\",\
\"config\":$REACTCONFIG\
}"
PROVIDERS="{\
\"awscloudformation\":$AWSCLOUDFORMATIONCONFIG\
}"

amplify init \
--amplify $AMPLIFY \
--frontend $FRONTEND \
--providers $PROVIDERS \
--yes

From https://docs.amplify.aws/cli/usage/headless/#sample-script

We can add to that script the "auth" category as it suggests in https://docs.amplify.aws/cli/usage/headless/#--categories:

#!/bin/bash
set -e
IFS='|'

REACTCONFIG="{\
\"SourceDir\":\"src\",\
\"DistributionDir\":\"build\",\
\"BuildCommand\":\"npm run-script build\",\
\"StartCommand\":\"npm run-script start\"\
}"
AWSCLOUDFORMATIONCONFIG="{\
\"configLevel\":\"project\",\
\"useProfile\":false,\
\"profileName\":\"default\",\
\"accessKeyId\":\"headlessaccesskeyid\",\
\"secretAccessKey\":\"headlesssecrectaccesskey\",\
\"region\":\"us-east-1\"\
}"
AMPLIFY="{\
\"projectName\":\"headlessProjectName\",\
\"envName\":\"myenvname\",\
\"defaultEditor\":\"code\"\
}"
FRONTEND="{\
\"frontend\":\"javascript\",\
\"framework\":\"react\",\
\"config\":$REACTCONFIG\
}"
PROVIDERS="{\
\"awscloudformation\":$AWSCLOUDFORMATIONCONFIG\
}"

AUTHCONFIG="{\
\"userPoolId\": \"myproject-userpool-id\",\
\"webClientId\": \"appid-web\",\
\"nativeClientId\": \"appid-native\",\
\"identityPoolId\": \"myproject-idp-poolid\"\
}"

CATEGORIES="{\
\"auth\":$AUTHCONFIG\
}"

amplify init \
--amplify $AMPLIFY \
--frontend $FRONTEND \
--providers $PROVIDERS \
--categories $CATEGORIES \
--yes

(Notice how i added the --categories parameter to the amplify init command).

The error message complains about googleAppIdUserPool and googleAppSecretUserPool being missing from the auth configuration, so we can add them to the AUTHCONFIG variable:

#!/bin/bash
set -e
IFS='|'

REACTCONFIG="{\
\"SourceDir\":\"src\",\
\"DistributionDir\":\"build\",\
\"BuildCommand\":\"npm run-script build\",\
\"StartCommand\":\"npm run-script start\"\
}"
AWSCLOUDFORMATIONCONFIG="{\
\"configLevel\":\"project\",\
\"useProfile\":false,\
\"profileName\":\"default\",\
\"accessKeyId\":\"headlessaccesskeyid\",\
\"secretAccessKey\":\"headlesssecrectaccesskey\",\
\"region\":\"us-east-1\"\
}"
AMPLIFY="{\
\"projectName\":\"headlessProjectName\",\
\"envName\":\"myenvname\",\
\"defaultEditor\":\"code\"\
}"
FRONTEND="{\
\"frontend\":\"javascript\",\
\"framework\":\"react\",\
\"config\":$REACTCONFIG\
}"
PROVIDERS="{\
\"awscloudformation\":$AWSCLOUDFORMATIONCONFIG\
}"

AUTHCONFIG="{\
\"userPoolId\": \"myproject-userpool-id\",\
\"webClientId\": \"appid-web\",\
\"nativeClientId\": \"appid-native\",\
\"identityPoolId\": \"myproject-idp-poolid\"\,\
\"googleAppIdUserPool\": \"my-google-client-id\"\,\
\"googleAppSecretUserPool\": \"my-google-client-secret\"\
}"

CATEGORIES="{\
\"auth\":$AUTHCONFIG\
}"

amplify init \
--amplify $AMPLIFY \
--frontend $FRONTEND \
--providers $PROVIDERS \
--categories $CATEGORIES \
--yes

And the init command runs successfully. I've tested it in Github Actions and runs fine.

asungomez avatar Feb 16 '23 09:02 asungomez

Closing as fix released with v12.0.0

akshbhu avatar May 16 '23 17:05 akshbhu

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.

github-actions[bot] avatar May 16 '23 17:05 github-actions[bot]

problem: [Amplify pull failed: auth headless is missing the following inputParams googleAppIdUserPool, googleAppSecretUserPool] could-be-solution: add environment variable in AWS Amplify (if you use Amplify) AMPLIFY_GOOGLE_CLIENT_ID xxxxxx.apps.googleusercontent.com AMPLIFY_GOOGLE_CLIENT_SECRET XXXXX-XXXXXX-XXXXX

problem: [Amplify pull failed: auth headless is missing the following inputParams googleClientId] could-be-solution: use "amplify pull" without -y

problem: https://xxxxxxx-dev.auth.ap-southeast-1.amazoncognito.com/error?error=redirect_mismatch&client_id=xxxxx could-be-causes: in aws-exports.js "oauth": { ..., "redirectSignIn": "http://localhost:3000/,https://main.xxxxxxxx.amplifyapp.com/", "redirectSignOut": "http://localhost:3000/,https://main.xxxxxxxx.amplifyapp.com/", "responseType": "token" *** the signIn,signOut redirect url is a combined string of two urls and invalid could-be-solution: in App.js try this: awsExports.oauth.redirectSignIn = ${window.location.origin}/oauth2/idpresponse/; awsExports.oauth.redirectSignOut = ${window.location.origin}/; Amplify.configure(awsExports); then run "amplify update auth" then run "amplify push -y" frontend need to run "amplify pull" before you run "git add ...", "git commit ...", "git push origin main" for CI-CD. in google, javascript origin uri put "https://xxxxxxxxxx-dev.auth.ap-southeast-1.amazoncognito.com/oauth2/idpresponse" or your hosting address in google, Authorized redirect URIs put "https://xxxxxxxxxx-dev.auth.ap-southeast-1.amazoncognito.com/oauth2/idpresponse/" or your hosting address

danny33118 avatar Jan 13 '24 03:01 danny33118