Swift: Sign in a user through OAuth

Examples

Sign in using a third-party provider

let url = try await supabase.auth.getOAuthSignInURL(provider: .github)

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 using a third-party provider with redirect

let url = try await supabase.auth.getOAuthSignInURL(
  provider: .google,
  redirectTo: URL(string: "https://example.com/welcome")!
)

Sign in with scopes

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