Skip to main content
Function Signature
A PortalAuth method and the first of the two steps that complete a magic link. A magic link signs in whoever opens it, to the account it was sent for, and anyone can request one for their own address and forward it to your user. Show the email this returns on your own confirmation screen, and call confirmMagicLink only once the user confirms it is theirs. The SDK provides no UI for this. Parameters
  • token: The token of the .magicLink that parseRedirect returned.
Returns
  • MagicLinkDetails: Contains the following:
    • email: String, the full email address the link signs in to. It is never masked; masking it, if you want to, is up to your screen.
MagicLinkDetails redacts itself when printed: "\(details)", String(reflecting:) and dump show <redacted> in place of the email. Read email to display it. Throws
  • PortalAuthError.invalidArgument(name: "token"): The token is empty or whitespace-only. Raised before any network call.
  • PortalAuthError.grantRejected: Portal refused the link (a 401): it has expired, was already used, or is otherwise unusable. Also raised without a request for a token that cannot be a Portal grant (characters outside the bearer-token alphabet). Not retryable: the user needs a new link — unless they already confirmed this link and are signed in, when there is nothing to do.
  • PortalAuthError.malformedResponse(path:missing:): The response carried no email.
  • PortalRequestsError.clientError: A 429. Each link can be looked up only a few times.
  • Other transport errors unchanged.
  • CancellationError: The calling task was already cancelled. Nothing is sent, so no lookup is spent.
Notes
  • Whatever it throws, do not confirm the link. A link whose email the user has not seen must not be exchanged.
  • Nothing is exchanged, persisted or remembered, and it does not wait for a confirmation in progress. The link stays usable until it expires, 15 minutes after it is sent.
  • Call it once per confirmation screen and keep the result while the user decides, rather than looking the link up again. A spent or forged link is rejected with .grantRejected before the lookup limit applies.
  • A link that has already been confirmed is spent, so this rejects it with .grantRejected; it never answers from memory. When iOS delivers a link again after the user confirmed it, send it straight to confirmMagicLink, which returns the remembered result. The SDK cannot tell that case apart from the token alone, so your app remembers which link the user confirmed — keep the AuthRedirect.MagicLink, which redacts the token when printed, rather than the bare string. That memory, like the SDK’s, lasts only while the app runs: after a relaunch, restore the session with restoreSession before routing redirects, and treat a .grantRejected for a link that arrives while the user is signed in as nothing to do.
  • Portal does not require this lookup before the exchange, and the SDK does not enforce it. Call it first in any case: it also reports an expired or already used link before the user is asked to confirm.
  • The email is personal data: show it, never log it.
  • Available starting from SDK version 8.2.0.
Example Usage
Related Documentation