Hello I am using AWS AppSync as the backend graphQL db. I am using Cognito to manage login, users and authentication. I am using IAM to manage identity rules, and guest users.
here is my inilization code:
let appSyncConfig = try AWSAppSyncClientConfiguration(appSyncServiceConfig: AWSAppSyncServiceConfig(),
credentialsProvider: AWSMobileClient.default(),
cacheConfiguration: AWSAppSyncCacheConfiguration())
// Initialize the AWS AppSync client
let appSyncClient = try AWSAppSyncClient(appSyncConfig: appSyncConfig)
appSyncClient.apolloClient?.cacheKeyForObject = { $0["id"] }
NOTE:: that I use default configurations, since all required information are in awsconfiguration.json
file
I am using the following functions from cognito to sign up users:
AWSCognitoIdentityUserPool.signUp
and follow a phone number verification, and at completion I use AWSMobileClient to sign in:
AWSMobileClient.default().signIn
THE ISSUE is:
after signing in, all the AppSync queries/mutations works without any issue BUT
after arbitrary time (usually 5 minutes) or at restarting the app
any AppSync queries/mutations that requires authorization RETURNS 401 (not authorized).
this issue continues until (what I think) the next time access/id tokens are refreshed (our configuration 1.5 hours), and the issue appears again after (5 min or restart).