Skip to main content
Function Signature
A PortalAuth method. Fetches a fresh authorize URL from Portal and returns it; your app opens it (for example with UIApplication.shared.open) and later forwards the redirect to handleRedirect. For a flow that also owns the browser, use signInWithGoogle. Returns
  • AuthorizeUrlResult: Contains the following:
    • authorizeUrl: String, the Google authorize URL, trimmed of surrounding whitespace.
Throws
  • PortalAuthError.authMethodUnavailable(.google): Google is not enabled for this auth environment. Not retryable; check getMethods().
  • PortalAuthError.accountAbstractionUnavailable(message:): isAccountAbstracted: true was requested but gas sponsorship is not enabled or configured.
  • PortalRequestsError.unauthorized: The redirectUrl is not on the environment’s allow list, the Auth Environment ID does not match an environment with authentication switched on, or an enabled provider is missing its credentials in the dashboard. That last case fails the call for every provider, not only the misconfigured one.
  • Other transport errors unchanged.
Notes
  • Call it on every tap and never cache the result. The URL embeds a single-use state shared by both provider URLs in one backend response, so a stale URL fails at the provider with no useful message.
  • The redirect arrives through the OS: onOpenURL in SwiftUI, or your scene or app delegate in UIKit. This path works with an https:// Universal Link redirect, which is the recommended production setup for redirect-based flows because another app cannot claim it; see Register your redirect.
  • If the user cancels at Google, Portal redirects to your redirectUrl with ?error=oauth_failed, which handleRedirect throws as PortalAuthError.authenticationFailed(error:).
  • Available starting from SDK version 8.0.0.
Example Usage
Related Documentation