For AI agents: the documentation index is at llms.txt. Guide pages have a markdown version at the same path with .md appended, before any query string or fragment.

Swift: Sign in a user through OAuth

Parameters

Examples

Sign in with OAuth using ASWebAuthenticationSession

let session = try await supabase.auth.signInWithOAuth(
  .github,
  options: OAuthOptions(redirectTo: URL(string: "my-app-scheme://callback")!),
  presenter: ASWebAuthenticationSessionPresenter(prefersEphemeralWebBrowserSession: true)
)

Sign in with OAuth and customize flow

let session = try await supabase.auth.signInWithOAuth(
  .github,
  presenter: ClosurePresenter { url, callbackScheme in
    // use url to start OAuth flow
    // and return the callback URL that contains the auth code.
    // ...
    return resultURL
  }
)

Sign in using a third-party provider

let flow = try await supabase.auth.oauthSignInURL(
  .github,
  options: OAuthOptions(redirectTo: URL(string: "my-app-scheme://callback")!)
)

// Open flow.url with your preferred method.
// When the app opens with the callback URL:
try await supabase.auth.handleRedirect(callbackURL)

Sign in with scopes

let session = try await supabase.auth.signInWithOAuth(
  .github,
  options: OAuthOptions(scopes: ["repo", "gist", "notifications"])
)