Hello everybody,
we have a question regarding a portal sign-out and a new sign-in without re-initializing portal and without restarting the app. The first login is working fine but when we logout (revoking and removing stored credentials) we would expect to receive a new challenge when calling portal.load() again and wait for portal.load() to complete the challenge and then continue in the code. But this ends in a weird behaviour, because portal.load() does not wait for challenge to complete. We are using a custom ArcGISAuthenticationChallengeHandler for handling challenges. We found out that after a sign-out with removing credentials, portal.load() is still in the loaded state when we try to sign-in after a sign-out and the load() function completes immediately which causes the weird behaviour in the app of course. Because at this point (the load() function) in the code it should stop and wait for the new challenge to complete and continue after successful sign-in. Why is that? Is the solution to re-initialize the portal-object again so that is in unloaded state or can we maybe reset the portal state from loaded to unloaded? For better understanding here is a code sample:
func signIn() async {
DispatchQueue.main.async {
self.isLoading = true
}
do {
try await setupPersistentCredentialStorage()
try await loadPortal()
isloggedIn = true
isLoading = false
} catch {
handleSignInError(error)
}
}
func removeCredentials() async {
await ArcGISEnvironment.authenticationManager.revokeOAuthTokens()
await ArcGISEnvironment.authenticationManager.clearCredentialStores()
}
func removeCredentialsAndLogout() {
Task {
await removeCredentials()
DispatchQueue.main.async {
self.isLoggedIn = false
}
}
}