PortalAuth method. Removes the session persisted for this authEnvironmentId, and forgets the grant this instance last exchanged (through confirmMagicLink, completeOAuthLogin or signInWith*) and any session from an accepted two-factor code that is still waiting to be written to the Keychain, so neither a redirect re-delivered after sign-out nor a repeated verifyTotp can bring back the session that was just cleared. It also cancels a Google or Apple sign-in in progress.
Throws
PortalAuthError.sessionStorageFailure(message:): A Keychain delete failed. Both the session and the sign-in in progress are always attempted; when both fail, the session’s failure is the one thrown.
- Cancels a Google or Apple sign-in in progress, including one
completeOAuthLoginorsignInWith*is already exchanging on this instance, which then throwsPortalAuthError.oauthFlowNotStartedinstead of returning a session. Wait for it to return before starting a new sign-in, and do not call it in your redirect handler beforecompleteOAuthLogin. Calling it afterloginWithGoogle()/loginWithApple()has returned a URL, or while a sign-in sheet is open, abandons that sign-in. A sign-in already at its two-factor step is not cancelled: its grant is already spent, andverifyTotpcan still complete it, so to abandon it, discard itsuserJwt. An exchange already in flight on anotherPortalAuthinstance with the same Auth Environment ID is not cancelled either. Available starting from SDK version 8.2.0. - Call it on sign-out, alongside
portal.clearSession(), and from youronSessionInvalidatedlistener before you show the sign-in screen.Portal.clearSession()invalidates the credential thePortalholds but does not reach whatPortalAuthkeeps: its memory of the last grant it exchanged, a session from an accepted two-factor code still waiting to be written, a session a sign-in stored after thatPortalwas built, or a Google or Apple sign-in in progress. - It is not a sign-out on its own. It does not affect a
Portalthat already holds the session (there is no server-side revoke); it prevents a futurerestoreSession()from returning it. Useportal.clearSession()for the live instance. - Waits for an exchange already running on this instance — from
confirmMagicLinkorverifyTotp— to finish persisting, then deletes the session it persisted. A Google or Apple exchange on this instance is cancelled instead, as above. An exchange on anotherPortalAuthinstance with the same Auth Environment ID is neither waited for nor cancelled: it completes, and the session it stores survives until that auth environment is cleared again, so on sign-out callclearPersistedSession()on every instance. AsignInWith*sheet that is still open is cancelled too, so its callback is refused, but the sheet stays on screen: on sign-out, cancel its task first. A sheet closed before it returns a result exchanges nothing. - A completion that finishes while this waits still returns its session to its caller, and that session keeps working in memory. If your app signed out while it ran, discard the result instead of adopting it.
- After it, confirming the same magic link again sends the spent grant to Portal, which rejects it with
PortalAuthError.grantRejected. Completing the same Google or Apple redirect again throwsPortalAuthError.oauthFlowNotStartedwithout a request, orPortalRequestsError.unauthorizedfrom Portal if a newer sign-in is in progress. - If your app remembers which magic link the user confirmed, forget it on sign-out too.
- Keychain items survive app deletion, so calling this on the first launch after install gives a fresh install a clean slate.
- Available starting from SDK version 8.0.0.