I'm currently using an OAuth library for handling login and logout in my app, and the login flow works fine. Safari opens for authentication and successfully redirects users back to my app once they log in.
However, I'm facing an issue during the logout process. When the user clicks logout, Safari opens the URL to perform the logout mechanism, but once it's complete, the user cannot return to the app. The redirection back to the app doesn't occur as expected, even though I have confirmed that the post_redirect_uri is correctly configured and matches the one used during login.
I'm currently using an OAuth library for handling login and logout in my app, and the login flow works fine. Safari opens for authentication and successfully redirects users back to my app once they log in.
However, I'm facing an issue during the logout process. When the user clicks logout, Safari opens the URL to perform the logout mechanism, but once it's complete, the user cannot return to the app. The redirection back to the app doesn't occur as expected, even though I have confirmed that the post_redirect_uri is correctly configured and matches the one used during login.
Share Improve this question asked Feb 6 at 5:11 Rushabh ShahRushabh Shah 3983 silver badges19 bronze badges1 Answer
Reset to default 0I would recommend using the Apple component
ASWebAuthenticationSession
( See https://developer.apple.com/documentation/authenticationservices/aswebauthenticationsession ). It basically presents, within your app, a Safari view controller-like which is acting like the SFSafariViewController
and it is isolated from the rest of the app. The main difference is that it will automatically close if a certain URL or scheme is triggered within the web page, so theoretically when you would trigger the logout, it could recognize a certain URL scheme for example, and it would automatically close. iOS side it would dismiss and you would get notified via completion handler. You can find examples, eg. at How to get an auth code using ASWebAuthenticationSession?