Skip to content

Instantly share code, notes, and snippets.

@fredriccliver
Created September 26, 2021 09:42
Show Gist options
  • Save fredriccliver/208826e38ddbfecbf01d305137abae58 to your computer and use it in GitHub Desktop.
Save fredriccliver/208826e38ddbfecbf01d305137abae58 to your computer and use it in GitHub Desktop.
guard let clientID = FirebaseApp.app()?.options.clientID else { return }
// Create Google Sign In configuration object.
let config = GIDConfiguration(clientID: clientID)
// Start the sign in flow!
GIDSignIn.sharedInstance.signIn(with: config, presenting: self) { [unowned self] user, error in
if let error = error {
print(error)
return
}
guard
let authentication = user?.authentication,
let idToken = authentication.idToken
else {
return
}
let credential = GoogleAuthProvider.credential(withIDToken: idToken, accessToken: authentication.accessToken)
Auth.auth().signIn(with: credential) { authResult, error in
if let error = error {
print(error)
return
}
// User is signed in
passToMainView()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment