Last active
August 12, 2020 15:06
-
-
Save popeating/97cf5065afc7a80c7f22cfce1a0709f8 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
const Glogin = async () => { | |
try { | |
//await GoogleSignIn.askForPlayServicesAsync(); | |
const result = await Google.logInAsync({ //return an object with result token and user | |
iosClientId: Constants.manifest.extra.IOS_KEY, //From app.json | |
androidClientId: Constants.manifest.extra.ANDROIUD_KEY, //From app.json | |
}); | |
if (result.type === 'success') { | |
console.log(result); | |
setIsLoading(true); | |
const credential = firebase.auth.GoogleAuthProvider.credential( //Set the tokens to Firebase | |
result.idToken, | |
result.accessToken | |
); | |
Firebase.auth() | |
.signInWithCredential(credential) //Login to Firebase | |
.catch((error) => { | |
console.log(error); | |
}); | |
} else { | |
//CANCEL | |
} | |
} catch ({ message }) { | |
alert('login: Error:' + message); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment