PortalAuth method. Reads the URL with parseRedirect and completes whatever it reads in one step: a magic link as confirmMagicLink would, without the confirmation, and a Google or Apple redirect as completeOAuthLogin would, bound to this device in the same way.
Parameters
url: The URL iOS delivered to your app, as aURL(fromonOpenURL, your scene delegate or your app delegate) or aString. TheURLoverload forwardsabsoluteString, so percent-encoding stays intact and the grant is decoded exactly once.
AuthResult?:nil: The URL is not for this instance — wheneverparseRedirectreturnsnil: it does not matchredirectUrl, carries bothauthMethodandlogin_type, carries noerrorparameter and either notoken(or an empty or whitespace-only one) or no recognized auth-method marker, is empty, or is longer than 8192 UTF-16 code units. Let your other URL handlers try..authenticated(AuthenticatedResult): The sign-in is complete.sessionis already saved to the Keychain; pass it toPortal(credentials:)..totpRequired(TotpRequiredResult): A two-factor code is required. Nothing is persisted; complete withverifyTotp.
PortalAuthError.authenticationFailed(error:): The URL matchesredirectUrland carries anerrorparameter, for exampleoauth_failed. Thrown even if a token is also present, and before any network call. The value is bounded to 100 characters.PortalAuthError.oauthFlowNotStarted: A Google or Apple redirect arrived with no sign-in in progress on this device, ascompleteOAuthLogindescribes. Nothing is sent, unlessclearPersistedSession()cancels the exchange while it runs. Start a new sign-in. Available starting from SDK version 8.2.0.PortalAuthError.invalidGrantResponse: The exchange returned neither a session token nor auserJwt.PortalAuthError.malformedResponse(path:missing:): The response did not carry the documented fields.PortalAuthError.sessionStorageFailure(message:): The Keychain failed this time: the Google or Apple sign-in in progress could not be read (nothing was sent), or the session could not be saved, so the sign-in is not returned (the grant is already spent). In both cases callinghandleRedirectagain with the same URL on the same instance retries: the exchange in the first case, the write in the second, without re-sending the grant.PortalRequestsError.unauthorized: Portal rejected the grant: it expired, was already exchanged, was issued for a different environment, or its sign-in method has since been disabled — or, for Google or Apple, it belongs to a sign-in other than the one in progress on this device. Also thrown when a remembered session has since been invalidated. UnlikeconfirmMagicLink, a refused magic link is reported this way too, not asPortalAuthError.grantRejected.- Other transport errors unchanged.
- Changed in 8.2.0: returns
nilfor a URL that carries bothauthMethodandlogin_type(previously exchanged as a magic link) and for atokenthat is only whitespace. Portal never sends either. - Each time it is given a magic link it logs a deprecation warning at the
.warnlevel. The log level is shared, starts at.none, is reset to.noneby everyPortalyou construct, and can only be raised withportal.setLogLevel(_:)after that; see Configure log level. A redirect is usually completed before anyPortalexists, so rely on Xcode’s deprecation warning at the call site. - It shares the remembered result with
confirmMagicLinkandcompleteOAuthLogin: a grant completed through either path replays the same way through the other, on the same instance and in the same process, while the session is live. A redirect that failed on a dropped connection is not remembered, so it can be retried; if Portal spent the grant before the connection dropped, the retry throwsPortalRequestsError.unauthorizedand the user needs a new sign-in.clearPersistedSession()drops the memory, and after the app is terminated the recovery isrestoreSession(); a Google or Apple redirect delivered again then fails, usually withoauthFlowNotStarted. - A grant that stopped at
.totpRequiredreplays as the same step. OnceverifyTotpaccepts the code, the same grant replays as the.authenticatedresult it resolved to. - Never log the raw URL; it contains the grant.
- Available starting from SDK version 8.0.0. Deprecated in 8.2.0.
handleRedirect call with parseRedirect and a completion per case: