Created
September 26, 2021 09:42
-
-
Save fredriccliver/208826e38ddbfecbf01d305137abae58 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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