I am using OAuth user authentication and when the user have authenticated successfully, I store their credential in the `arcGISCredentialStore`.
Something like this:
let oAuthUserConfig = OAuthUserConfiguration(portalURL: portalUrl, clientID: authConfig.clientId, redirectURL: redirectUrl)
ArcGISEnvironment.authenticationManager.arcGISAuthenticationChallengeHandler = EsriChallengeHandler(oAuthUserConfigurations: [oAuthUserConfig])
Task {
do {
let oAuthUserCredential = try await OAuthUserCredential.credential(for: oAuthUserConfig)
ArcGISEnvironment.authenticationManager.arcGISCredentialStore.add(oAuthUserCredential)
} catch {
print(" >> Error obtaining OAuthUserCredential: \(error)")
}
}My problem is that after the user is authenticated, the credentials are stored in the credential store properly but when I restart the app, the credential store is empty and it triggers for authentication again.
Am I doing something wrong or is there maybe a bug? I'm using 200.4.0.
FYI This is the challenge handler:
@MainActor
final class EsriChallengeHandler: ArcGISAuthenticationChallengeHandler {
let oAuthUserConfigurations: [OAuthUserConfiguration]
public init(oAuthUserConfigurations: [OAuthUserConfiguration] = []) {
self.oAuthUserConfigurations = oAuthUserConfigurations
}
func handleArcGISAuthenticationChallenge(_ challenge: ArcGISAuthenticationChallenge) async throws -> ArcGISAuthenticationChallenge.Disposition {
if let configuration = oAuthUserConfigurations.first(where: { $0.canBeUsed(for: challenge.requestURL) }) {
do {
let credential = try await OAuthUserCredential.credential(for: configuration)
ArcGISEnvironment.authenticationManager.arcGISCredentialStore.add(credential)
return .continueWithCredential(credential)
} catch {
return .cancel
}
}
print("No matching configuration found for challenge")
return .cancel
}
} Thank you.