Skip to content

Instantly share code, notes, and snippets.

@popeating
Last active August 12, 2020 15:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save popeating/97cf5065afc7a80c7f22cfce1a0709f8 to your computer and use it in GitHub Desktop.
Save popeating/97cf5065afc7a80c7f22cfce1a0709f8 to your computer and use it in GitHub Desktop.
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