1

I have an iOS app that uses an AppSync GraphQL API created with AWS Amplify. I want some queries to be available with public auth (for unauthenticated users) via IAM. For this public case, when calling the API, I get the following error from AWSAppSync/AWSAppSyncClient/AWSAppSyncHTTPNetworkTransport.swift:

Fatal error: Credentials Provider and endpoint not set

The AppSync initialization is done in the 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)

I noticed in AWSAppSyncClientConfiguration#makeNetworkTransportForIAM that the resolvedCredentialsProvider is nil:

// Evaluates to nil
let resolvedCredentialsProvider = authProvider ?? AWSServiceInfo().cognitoCredentialsProvider

Do I need to create a credentials provider and pass it to the AppSync client config? How can I use IAM for unauthenticated users?

Benck
  • 515
  • 1
  • 5
  • 17

0 Answers0