I am using AWS amplify to build the backend of my ios application. I am having an issue initializing appsync client. I have added Auth to the backend and have signed in but I am getting the following error in the console:
CONSOLE:
Error initializing appsync client. invalidAuthConfiguration("AWSCognitoUserPoolsAuthProvider cannot be nil.")
In AppDelegate:
// CONFIGURE AWSAppSync
do {
// You can choose your database location if you wish, or use the default
let cacheConfiguration = try AWSAppSyncCacheConfiguration()
// AppSync configuration & client initialization
let appSyncConfig = try AWSAppSyncClientConfiguration(appSyncServiceConfig: AWSAppSyncServiceConfig(), cacheConfiguration: cacheConfiguration)
appSyncClient = try AWSAppSyncClient(appSyncConfig: appSyncConfig)
print("appSyncClient initialise success \n")
} catch {
print("Error initializing appsync client. \(error)")
}
I am just guessing here but 'appSyncConfig' variable should be:
let appSyncConfig = try AWSAppSyncClientConfiguration(appSyncServiceConfig: AWSAppSyncServiceConfig.init(), cacheConfiguration: cacheConfiguration, userPoolsAuthProvider: AWSCognitoUserPoolsAuthProvider?)
But how do i get AWSCognitoUserPoolsAuthProvider????
In configuring the AWS AppSync you are missing a step which is adding the class to get the tokens from Cognito User Pools. Of course, here I assume that you have chosen Cognito User Pool as your default authorization type!
Please let me know if you have any more concerns about to setup amplify GraphQL or whatever!