How to sign-out with SFAuthenticationSession

1.9k Views Asked by At

I use SFAuthenticationSession to sign in with SSO to login.microsoftonline.com. It works completely fine but there is an issue with logging out. SFAuthenticationSession doesn't provide a way to clear cookies. Therefore when I call SFAuthenticationSession.start() again I get previous callback url with authentication token instead of allowing a user to provide new credentials.

As a workaround I call login.microsoftonline.com/common/oauth2/logout with SFAuthenticationSession.start(). It works but the UX experience is worse than terrible.

Is there really no other way to clear cookies with SFAuthenticationSession? Session isn't shared with Safari so opening a webview woudln't work neither.

Would ASWebAuthenticationSession instead of SFAuthenticationSession allow clearing cookies somehow?

I know that quite similar questions have been already asked on SO but maybe there is some update on this topic.

1

There are 1 best solutions below

0
On

The only way to make logout is call login.microsoftonline.com/common/oauth2/logout or if you want to use sso between your applications you can use WKWebView, but if you want use sso between Safari and your app the only way is ASWebAuthenticationSession or SFAuthenticationSession. ASWebAuthenticationSession is same as SFAuthenticationSession but they add permission alert view and when you need logout, user will see alert view with question: Do you want to sign in? Hope Apple will fix it