question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't re-authenticate with Google/Facebook on app hard-restart

See original GitHub issue

How to reproduce:

  1. Login to your account
  2. Close the app and remove it from the task view
  3. Reopen the app
  4. Call reauthenticate()

IS: Error: Not logged in with google or Not logged in with facebook

SHOULD: Re-authenticate

On restart the variables

// firebase.android.js - Line 10,11,12
firebase._rememberedContext = null;
firebase._googleSignInIdToken = null;
firebase._facebookAccessToken = null;

are reset to null. They should be stored in the appSettings.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:22 (17 by maintainers)

github_iconTop GitHub Comments

2reactions
witi83commented, Nov 30, 2017

After reviewing the code base (specifically login) and the firebase documentation, it seems to me that you are correct: Anonymous users have to be linked as well!

However, I’m still curious about two things: First, why this change fixes the ominous FirebaseAuthUserCollisionException, which occured to a couple of people. Obviously, the real reason lies somewhere else. And second, why didn’t we observe the creation of two users as well. This is something I have to investigate.

In the meantime @EddyVerbruggen , feel free to revert it.

Thanks for @RaphaelJenni reporting!

1reaction
RaphaelJennicommented, Nov 29, 2017

This is my code in a condensed way. You can extract the code you want for the README.

const fbase = require('nativescript-plugin-firebase');

//********************************

private static setAuthenticationToken(googleSignInToken: string, facebookSignInToken: string){
        const authTokens: AuthTokens = {
            googleSignInIdToken: googleSignInToken,
            facebookSignInToken: facebookSignInToken
        };
        
	this.secureStorage.set({
                key: UserService.SECURE_STORAGE_AUTH_TOKEN_KEY,
                value: JSON.stringify(authTokens)
            })
        );
}

private static getAuthenticationToken() {
        return JSON.parse(this.secureStorage.get({
                key: UserService.SECURE_STORAGE_AUTH_TOKEN_KEY
          }));
}

private static clearAuthenticationToken$() {
    this.secureStorage.remove({key: UserService.SECURE_STORAGE_AUTH_TOKEN_KEY});
}
	
//********************************
	
this.firebase.login({type: loginType})
   .then(() => UserService.setAuthenticationToken(fbase._googleSignInIdToken, fbase._facebookAccessToken))
			
			
//********************************
	
	
const reAuthenticationOptions = getAuthenticationToken();
	
fbase._googleSignInIdToken = authTokens.googleSignInIdToken;
fbase._facebookSignInToken = authTokens.facebookSignInToken;
	
this.firebase.reauthenticate(/*REAUTHENTICATION OPTIONS*/)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Recover Your Facebook Account if You Can't Log In.
Go to the Find Your Account page at facebook.com/login/identify and follow ... Learn what to do if you can't reset your password because...
Read more >
Can't sign in from a third-party service - Google Account Help
A general error that your sign-in was unsuccessful. · The service you're signing in from doesn't provide enough information to prove it's you....
Read more >
How to Log Into Facebook If You Lost Access to Code Generator
Yes, you can access Facebook without a confirmation or reset code. Facebook's Code Generator is only one of many layers of Facebook security....
Read more >
7 ways to troubleshoot if Facebook is not working on your device
Refresh your browser · Check to see if Facebook is online · Clear your browser's cache · Close and reopen the app ·...
Read more >
How to Recover Your Facebook Account When You Can't Login
So you forgot your Facebook login and password and can't log into Facebook anymore? Or was your Facebook account hacked, meaning you can't...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found