I'm working with Amplify, I added the authentication to my application and my graphQL schema is with rule private, all things work good in my local, each graphQl api called, It contains the access token and appSync accept my request. But when I deploy my App, I get an error because all my graphQl request still with api-key not with access token.
In the console I use this configuration:
In my local : all thins work good after authentication.
In production : graphQl still with api-key after authentication
Based on this documentation I ran amplify update api
:
From there the command line prompts you to select the API type:
? Please select from one of the below mentioned services:
> `GraphQL`
? Select a setting to edit:
> `Authorization modes`
? Choose the default authorization type for the API
API key
Amazon Cognito User Pool
❯ IAM
OpenID Connect
I updated the default authorization type for the API to be Amazon Cognito User Pool
instead of API key
.
Then I had to run amplify push --appId YOUR_APP_ID --envName YOUR_STAGING_ENV
to sync up the changes.