我有一个使用 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/