I'm trying to build a site where the user can first login anonymously using firebase and then convert his account to permanent by signing in with facebook. I'm following the instructions given at https://firebase.google.com/docs/auth/web/anonymous-auth but i'm getting the following error "Uncaught ReferenceError: response is not defined". I also tried converting the account using Google Sign in but then i get the error "googleUser is not defined". What am i doing wrong?
This is my code:-
<html>
<body>
<button onclick = "anonymousLogin()">Anonymous Signin</butto>
<button onclick = "facebookSignin()">Facebook Signin</button>
<button onclick = "facebookSignout()">Facebook Signout</button>
</body>
<script>
function anonymousLogin(){
firebase.auth().signInAnonymously().catch(function(error) {
// Handle Errors here.
var errorCode = error.code; console.log(errorCode)
var errorMessage = error.message; console.log(errorMessage)
});
}
function facebookSignin() {
var provider = new firebase.auth.FacebookAuthProvider();
var credential = firebase.auth.FacebookAuthProvider.credential(
response.authResponse.accessToken);
auth.currentUser.link(credential).then(function(user) {
console.log("Anonymous account successfully upgraded", user);
}, function(error) {
console.log("Error upgrading anonymous account", error);
});
}
</script>
</html>
response.authResponse.accessToken
as the argument ... what isresponse
? You've not shown any code that creates a variable calledresponse
- Jaromanda X