Skip to main content
Function Signature
A PortalAuth method. Reads the URL locally and synchronously: it sends nothing to Portal, touches no storage, logs nothing and uses up no grant, so it is safe to call on every URL your app receives. Complete the result with the method for its case: getMagicLinkDetails and, once the user confirms the email, confirmMagicLink for a magic link; completeOAuthLogin for Google or Apple. Parameters
  • url: The URL iOS delivered to your app, as a URL (from onOpenURL, your scene delegate or your app delegate) or a String. The URL overload forwards absoluteString, so percent-encoding stays intact and the grant is decoded exactly once.
Returns
  • AuthRedirect?:
    • .magicLink(AuthRedirect.MagicLink): A magic link. Pass its token to getMagicLinkDetails, show the user the email, and call confirmMagicLink only once they confirm it.
    • .oauth(AuthRedirect.OAuth): A Google or Apple grant. provider is .google or .apple. Pass every one to completeOAuthLogin: it completes only the sign-in this device started, so a grant someone else obtained, opened through your redirect URL by a web page, message or app, signs nobody in.
    • .failed(error:): The sign-in did not complete — the user cancelled, the provider rejected it, or it failed for any other reason — so Portal redirected with an error in the URL (error=oauth_failed) instead of a grant. Nothing was sent to Portal. The value is bounded to 100 characters, but it comes from an inbound URL that any app or website can open, so show your own text rather than the raw value.
    • nil: The URL is not a Client Auth redirect for this instance. Let your other URL handlers try. Returned when the URL:
      • is empty or longer than 8192 UTF-16 code units (checked before it is parsed),
      • does not target this instance’s redirectUrl (scheme and host compared case-insensitively, the path case-sensitively, ignoring trailing slashes and surrounding whitespace),
      • carries both authMethod and login_type (Portal never sends both), or
      • carries no error parameter and either no token (or an empty or whitespace-only one) or no sign-in marker this SDK recognizes.
Throws Nothing. A redirect that reports an error is .failed(error:). Types
Notes
  • Only parseRedirect can build a .magicLink or .oauth value; their initializers are not public.
  • Printing an AuthRedirect (description, debugDescription, dump) shows <redacted> in place of the token. Equatable and Hashable still compare the real token, so two values for the same link are equal. MagicLink.token read on its own is a plain String, so keep the MagicLink value rather than the bare token, and never log or persist it.
  • Unless it carries both authMethod and login_type, a redirect that carries ?error=… is .failed(error:), even when it also carries a token or a sign-in marker, and its token is never handed out.
  • Magic-link redirects carry authMethod=EMAIL_MAGIC_LINK; Google and Apple redirects carry login_type=GOOGLE or login_type=APPLE. Both are matched exactly. See What Portal appends.
  • If your redirect URL already carries a token parameter, the last occurrence is read, which is always the one Portal appended.
  • Never log the raw URL; it contains the grant.
  • Available starting from SDK version 8.2.0.
Example Usage
Related Documentation