How to access/verify the contents of the firebase auth object when using firebase simple login?

StackOverflow https://stackoverflow.com/questions/21593074

  •  07-10-2022
  •  | 
  •  

Pregunta

Is it possible to access/verify the contents of the firebase auth object when using firebase simple login? It would be useful for debugging / configuring security rules.

¿Fue útil?

Solución

For additional debugging of the auth. token and security rules when using Firebase Simple Login, you have two great tools at your disposal:

  1. Enable debug mode, by passing the optional debug: true flag when generating a custom Firebase token. You cannot do this automatically when using the delegated authentication service due to security constraints, but you may generate tokens yourself via Custom Login.

Also, try enabling debug-mode on the client library with the following command, which will yield additional information such as the paths being read from or written to, and the data going over the wire:

`Firebase.enableLogging(true, true);`

`authClient.login('twitter', { debug: true });`
  1. As you suggest, take a peek at the contents of the authentication token. There are a few ways to do this. The easiest is to manually pass it to firebaseRef.auth(), and examine the response payload that is returned in the callback, which contains the contents of the auth. token. Alternatively, since all Firebase auth. tokens follow the open JSON Web Token (JWT) standard, you can parse the contents of the auth. token by Base64-decoding each of the token sequences, separated by a period (.).

Normally, Firebase Simple Login automatically handles this step for you, but you can manually call ref.auth(<token>, function(authData) { ... });, where the token is available via user.firebaseAuthToken after authenticating with Simple Login.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top