AppAuth-iOS: Logout function not working on iOS > 14
Hello, I’m experiencing an issue on iOS > 14. The logout function “OIDEndSessionRequest” isn’t working correctly and I can’t complete the logout procedure.
This is my code:
let config = OIDServiceConfiguration(authorizationEndpoint: URL(string: AUTHORIZATION_ENDPOINT)!, tokenEndpoint: URL(string: TOKEN_ENDPOINT)!, issuer: URL(string: ISSUER)!, registrationEndpoint: URL(string: REGISTRATION_ENDPOINT)!, endSessionEndpoint: URL(string: END_SESSION_ENDPOINT)!)
let logoutRequest = OIDEndSessionRequest(configuration: config, idTokenHint: (authState?.lastTokenResponse?.refreshToken)!, postLogoutRedirectURL: URL(string: "REDIRECT_URI")!, state: (authState?.lastAuthorizationResponse.state)!, additionalParameters: nil)
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "myView") as! MyViewController
let userAgent = OIDExternalUserAgentIOS(presenting: vc)
OIDAuthorizationService.present(logoutRequest, externalUserAgent: userAgent!, callback: { (authorizationState, error) in })
The error code received is: “Error Domain=org.openid.appauth.general Code=-3”
Can you help me please?
Thanks in advance
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 17
We have a solution for our issue. We figured out that the OIDEndSessionRequest’s
idTokenHintparameter needs theidTokenand not arefreshToken.We are in a similar predicament as the OP. We call the the
OIDEndSessionRequestthe same way but here is what happens after that.We are presented with an alert that’s named
Sign-in. We saw that others had this issue and that there’s no way to correct that outside of AppAuth. So we are not too concerned about this and tap theContinuebutton.We are then presented with a logout page where we are asked to tap the
Sign outbutton. Tapping the button updates the page now displayingYou are now signed out. Here’s the problem: The page is never dismissed and the session callback is never called. Only by tapping theCancelbutton at the top of the screen will we get the error:Error Domain=org.openid.appauth.general Code=-3 "(null)" UserInfo={NSUnderlyingError=0x600000438450 {Error Domain=com.apple.AuthenticationServices.WebAuthenticationSession Code=1 "(null)"}}Any help would be greatly appreciated!
Indeed, but my main problem with this is, that this way the cookie will not be erased and upon the next login this will be seen by the user.