Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
4 tasks done
JackPenney opened this issue Dec 1, 2021 · 15 comments
Assignees
Labels
auth Issues tied to the auth category of the CLI bug Something isn't working ops-auth Operational theme: auth category p1 strategic

Comments

@JackPenney
Copy link

Before opening, please confirm:

  • I have installed the latest version of the Amplify CLI (see above), and confirmed that the issue still persists.
  • I have searched for duplicate or closed issues.
  • I have read the guide for submitting bug reports.
  • 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: aws-amplify/amplify-js#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

@InnovateWithEric InnovateWithEric added headless Headless mode for CI/CD pending-triage Issue is pending triage auth Issues tied to the auth category of the CLI labels Dec 2, 2021
@josefaidt josefaidt removed the headless Headless mode for CI/CD label Dec 3, 2021
@josefaidt
Copy link
Contributor

Hey @JackPenney 👋 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 josefaidt added bug Something isn't working and removed pending-triage Issue is pending triage labels Dec 6, 2021
@ganipcanot
Copy link

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

@ammarkarachi
Copy link
Contributor

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

@JackPenney
Copy link
Author

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)

@giangchau92
Copy link

Is the bug resolved? I am facing with this issue

@edwardfoyle edwardfoyle removed their assignment Nov 7, 2022
@ignitum-ryan
Copy link

@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).

@tim-g-provectusalgae
Copy link

tim-g-provectusalgae commented Dec 5, 2022

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.

@ignitum-ryan
Copy link

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.

@hanna-becker
Copy link

hanna-becker commented Feb 8, 2023

Facing the same issue with amplify-cli 10.7.1.

@ignitum-ryan
Copy link

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.

@hanna-becker
Copy link

hanna-becker commented Feb 8, 2023

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.

@asungomez
Copy link

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.

@akshbhu
Copy link
Contributor

akshbhu commented May 16, 2023

Closing as fix released with v12.0.0

@akshbhu akshbhu closed this as completed May 16, 2023
@github-actions
Copy link

⚠️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.

@danny33118
Copy link

danny33118 commented Jan 13, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auth Issues tied to the auth category of the CLI bug Something isn't working ops-auth Operational theme: auth category p1 strategic
Projects
None yet
Development

No branches or pull requests