我有一个 iOS 应用程序,它使用通过 AWS Amplify 创建的 AppSync GraphQL API。我希望通过 IAM 可以使用公共身份验证(对于未经身份验证的用户)进行一些查询。对于这个公共案例,在调用 API 时,我收到以下错误AWSAppSync/AWSAppSyncClient/AWSAppSyncHTTPNetworkTransport.swift
:
Fatal error: Credentials Provider and endpoint not set
AppSync 初始化在 AppDelegate 中完成:
let serviceConfigIAM = try AWSAppSyncServiceConfig(forKey: "bookapi_AWS_IAM")
let cacheConfigIAM = try AWSAppSyncCacheConfiguration(useClientDatabasePrefix: true, appSyncServiceConfig: serviceConfigIAM)
let clientConfigIAM = try AWSAppSyncClientConfiguration(appSyncServiceConfig: serviceConfigIAM, cacheConfiguration: cacheConfigIAM)
appSyncClient = try AWSAppSyncClient(appSyncConfig: clientConfigIAM)
我注意到AWSAppSyncClientConfiguration#makeNetworkTransportForIAM
resolvedCredentialsProvider 为零:
// Evaluates to nil
let resolvedCredentialsProvider = authProvider ?? AWSServiceInfo().cognitoCredentialsProvider
我是否需要创建凭据提供程序并将其传递给 AppSync 客户端配置?如何将 IAM 用于未经身份验证的用户?