如何更改AWS放大AppSync默认授权模式表单API键为Cognito用户池?

发布于 2025-02-02 15:27:24 字数 1359 浏览 6 评论 0原文

我正在使用 Amplify ,我将身份验证添加到了我的应用程序中,而我的GraphQl架构则使用prival private,所有事物在我的本地中效果很好,每个GraphQl API都称为,它包含 < strong>访问令牌 和appsync接受我的要求。 但是,当我部署应用程序时,我会遇到一个错误,因为我的所有GraphQl请求仍然 api-key nocess occess令牌。

我的schema.graphql

我的awsappsyncclient

在控制台中我使用此配置

在我的本地: 身份验证后所有细胞都很好。

在生产中: graphQl在身份验证之后仍在API-KEY

”

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.

my schema.graphQl
enter image description here

My AWSAppSyncClient
enter image description here

In the console I use this configuration:
enter image description here

In my local : all thins work good after authentication.

enter image description here

In production : graphQl still with api-key after authentication

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心意如水 2025-02-09 15:27:24

基于此文档> amplify update api :

从那里,命令行提示您选择API类型:

? 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

我更新了API的默认授权类型为Amazon cognito cognito cognito用户池而不是api键

然后,我必须运行amplify push -appid our_app_id -envname your_staging_env才能同步更改。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文