首页 > 解决方案 > 未经身份验证的用户的 AWS Amplify API 身份验证错误

问题描述

我使用 Amplify 为 iOS 应用程序创建了一个书籍 API。我希望 book 表对经过身份验证和未经身份验证的用户都具有读取权限。这是架构:

type Book
  @model
  @searchable
  @auth(
    rules: [
      {allow: private, provider: userPools, operations: [read]},
      {allow: groups, groups: ["Admin"]}
    ]
  )
{
  id: ID!
  category: BookCategoryType!
  description: String
  groupsCanAccess: [String]!
  images: [Image!]
    @auth(rules: [
        {allow: groups, groupsField: "groupsCanAccess", operations: [read]},
        {allow: groups, groups: ["Admin"]}
    ])
  title: String!
}

但是,从 调用fetchAWSAppSyncClient,出现以下错误:

authenticationError(AWSMobileClient.AWSMobileClientError.notSignedIn(message: "User is not signed in, please sign in to use this API."))

Cognito 身份池已Enable access to unauthenticated identities检查并且存在未经身份验证的 IAM 角色。

可能是什么问题呢?

标签: amazon-cognitoaws-amplifyaws-appsyncaws-sdk-iosaws-amplify-cli

解决方案


推荐阅读