Swift: Sign in a user through OAuth

Parameters

Examples

Sign in with OAuth using ASWebAuthenticationSession

let session = try await supabase.auth.signInWithOAuth(
  provider: .github
) \{ (session: ASWebAuthenticationSession) in 
  // customize session
\}

Sign in with OAuth and customize flow

let session = try await supabase.auth.signInWithOAuth(
  provider: .github
) \{ url in 
  // use url to start OAuth flow
  // and return a result url that contains the OAuth token.
  // ...
  return resultURL
\}

Sign in using a third-party provider

let url = try await supabase.auth.getOAuthSignInURL(provider: .github, redirectTo: URL(string: "my-app-scheme://"))

let session = ASWebAuthenticationSession(url: url, callbackURLScheme: "my-app-scheme") \{ url, error in 
  guard let url else \{ return \}

  Task \{
    try await supabase.auth.session(from: url)
  \}
\}

session.presentationContextProvider = self // yours ASWebAuthenticationPresentationContextProviding implementation.

session.start()

Sign in with scopes

let url = try await supabase.auth.signInWithOAuth(
  provider: .github,
  scopes: "repo gist notifications"
)