aws-amplify - AWS Amplify 未经授权的错误 - 无权访问 [...] 类型的 [...]

标签 aws-amplify

我有一个使用 google federate 登录的 AWS Amplify 应用程序。 这是我的数据模型。

type TriadeMetric @model @auth(rules: [{allow: owner}]) {
  id: ID!
  NoteMetrics: [NoteMetric] @hasMany(indexName: "byTriadeMetric", fields: ["id"])
}

enum MetricEnum {
  ACCURACY
  DURATION
}

type NoteMetric @model @auth(rules: [{allow: owner}]) {
  id: ID!
  metricType: MetricEnum
  value: Float
  triademetricID: ID! @index(name: "byTriadeMetric")
  semitones: Int
}

当我尝试使用

创建新记录时
const triadeMetric = await DataStore.save(new TriadeMetric({}));

我收到这条警告信息:

[{"errorType":"Unauthorized","message":"Not Authorized to access onCreateTriade on type Triade"}]}

这个错误:

{"errors":[{"errorType":"Unauthorized to access onCreateTriade on type Triade"}]}

最佳答案

我使用了错误的身份验证类型: 在 aws-exports.js 中 我替换了 "aws_appsync_authenticationType": "API_KEY" 使用 "aws_appsync_authenticationType": "AMAZON_COGNITO_USER_POOLS"

关于aws-amplify - AWS Amplify 未经授权的错误 - 无权访问 [...] 类型的 [...],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73141849/

相关文章:

aws-cloudformation - 如何使 Amplify CloudFormation 了解外部所做的更改

aws-amplify - 自定义 withAuthenticator HOC 组件的颜色

react-native-navigation - 如何在 Android 中将 React native 导航与 AWS Amplify 推送通知集成?

amazon-web-services - 使用 CloudFormation 配置 Amazon Cognito 域

react-native - 如何配置 Amplify 以使用多个 AppSync 端点?

android - AWS Cognito 规则无法匹配使用 aws amplify (Android) 的插入式身份验证 UI

amazon-web-services - 放大更新<category>覆盖模板更改

node.js - aws-sdk/clients/cognitoidentity 没有导出成员 'String'

amazon-web-services - aws amplify 可以与 NextJS 配合使用吗?

amazon-web-services - 如何在使用 Amazon Cognito 进行身份验证时公开访问 AWS AppSync GraphQL API?