Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jacobsapps/193b0a995a4234b5444dc6d6c185bd50 to your computer and use it in GitHub Desktop.
Save jacobsapps/193b0a995a4234b5444dc6d6c185bd50 to your computer and use it in GitHub Desktop.
import AuthenticationServices
func signInWithGoogle() async throws -> String {
try await withCheckedThrowingContinuation { continuation in
let session = ASWebAuthenticationSession(
url: URL(string: "https://oauth.example.com/auth")!,
callbackURLScheme: "myapp"
) { callbackURL, error in
if let error = error {
continuation.resume(throwing: error)
} else if let token = callbackURL?.lastPathComponent {
continuation.resume(returning: token)
}
}
session.start()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment