logout
AppDelegate.reachfive().logout(webSessionLogout request: WebSessionLogoutRequest? = nil, revoke token: AuthToken? = nil) async throws
Description
Terminates the main SSO session, all provider sessions, and optionally revokes user tokens or initiates a web-based logout.
-
Provider Sessions: Logs out from all configured identity providers (e.g., Google, Facebook).
-
Web Session Logout: When a
WebSessionLogoutRequestis provided via thewebSessionLogoutparameter, triggers a web-based logout by opening a web authentication session to the server’s logout endpoint (e.g.,/logout). -
Token Revocation: When an
AuthTokenis provided via therevokeparameter, revokes the specified token, invalidating the user’s session. This applies to both access and refresh tokens. -
Main SSO Session: Terminates the core SSO session.
Both webSessionLogout and revoke are optional and default to nil.
If neither is provided, the method logs out from provider sessions and the main SSO session but does not revoke specific tokens or clear browser cookies.
Examples
// Basic logout (no parameters)
do {
try await AppDelegate.reachfive().logout()
// User is logged out from provider sessions and main SSO session
// Tokens are not revoked, and browser cookies are not cleared
} catch {
// Handle ReachFiveError
}
// Native logout with token revocation
do {
let authToken = // Obtain AuthToken from storage or authentication
try await AppDelegate.reachfive().logout(revoke: authToken)
// User is logged out, tokens are revoked
} catch {
// Handle ReachFiveError
}
// Web-based logout with redirect
do {
let WebSessionLogoutRequest = WebSessionLogoutRequest(
origin: "app_logout",
presentationContextProvider: // Provide a context provider, e.g., a view controller
)
try await AppDelegate.reachfive().logout(webSessionLogout: WebSessionLogoutRequest)
// Browser cookies are cleared, user is redirected
} catch {
// Handle ReachFiveError
}
Parameters
optional The web session logout request. Defaults to If provided, triggers a web-based logout by opening a web authentication session to the server’s logout endpoint. The URL must be defined in your ReachFive Console settings at . |
|||
Use This class is only needed for apps using web-based SSO. Includes:
|
|||
optional The authentication token to revoke, invalidating the user’s session.
Use Defaults to
|
Response
Error: ReachFiveError
ReachFiveError
Based on the problem, the ReachFiveError will be:
-
AuthCanceled: The user cancelled the request or no credential was available in the keychain. -
RequestError(apiError: ApiError)for a Bad Request (status 400) error. -
AuthFailure(reason: String, apiError: ApiError?)mainly for Unauthorized (status 401) error. -
TechnicalError(reason: String, apiError: ApiError?)if it’s an Internal Server Error (status 500) or other internal errors.
ApiError
error |
The main error message. |
||||||
errorId |
The identifier of the error. |
||||||
errorUserMsg |
The user-friendly error message.
|
||||||
errorMessageKey |
The error message key. |
||||||
errorDescription |
The technical error message. |
||||||
errorDetails FieldError[] |
|