Firebase Auth. How to generate idToken for other uses?

How can I know the idToken of the current user with the current setup of firebase in Appgyver?

The idToken is useful to use some Firebase functions by REST API.

There is a way to get an idToken knowing the refreshToken by REST API. It has a bug, I need refreshToken id but both the “Email & password authentication (Firebase Auth)” and the “Get current user (Firebase Auth)” return the refreshToken = EMPTY.

Any idea?

1 Like

I totally agree with you. I have been trying to get idToken with no luck. I asume there is a bug or it is hidden inside an object.

Meanwhile the flow function “Get current user (Firebase Auth)” shows the refreshToken (at least my app does not show the error anymore).

STILL:
equally important is to know the idToken , because only with the idToken can the app read or write data with the flow function “HTTP-request”, as soon as security rules are in place.

The idToken is completely missing in the out put arguments of “Get current user (Firebase Auth)”:

image

1 Like

Hi,
May I know how you can get it? I am using the below:

outputs["Get current user (Firebase Auth)"].currentUser.refreshToken

in my case this (outputs[“Get current user (Firebase Auth)”].currentUser.refreshToken) only works in the web app, in android and ios show as empty.

Tracker

Same here. Only works in the web!

This is the error message I am getting when using android:

You are right, I also only get the refresh token in the web preview and not in iOS preview. Same like what you are seeing.

I am afraid, I now have to delete the “ Email & password authentication (Firebase Auth) ” as security rules together with HTTP requests are impossible to use without the idToken. Very sad :worried:

After all, I found this course on udemy, that has a section about connecting Firebase and AppGyver securly with the flow function “HTTP request”: https://www.udemy.com/course/firebase-meets-appgyver/

1 Like

Until I have a better solution I have combined the two solutions. appgyver’s new firebase email and password connection works fine to create a permanent connection that refreshes itself. the signin by http request generates a session that lasts 3600 seconds and then you have to refresh the idToken. in my case I have used the firebase authentication login page adding and reconnecting via http request when they log in. this seems unproductive but in my case it works, when the application refreshes they reconnect through the two sites obtaining an idToken via http request to use it in Path or in other practical matters. In my case I only need the idToken to create records via PATH in firebase and authorize some operations that need head authentication because Create Records via appgyver does not allow customizing the id of the document, as soon as they solve those problems or add those functions to appgyver the connection via http request will not be needed. a greeting.

Dear @Sergio_Invernizzi
Can you please explain that a bit more? May be with the help of screenshots

I would like to follow this method. Thank You

Dear @Sergio_Invernizzi
Can you please explain that a bit more? May be with the help of screenshots. Thank You

Hey guys,

I had the same problem - only getting the id token on my PC and not my Android phone.

but I tried to get the id token by using Sign in with email / password and it works on my Android phone!!

use outputs[“HTTP request”].resBody[‘idToken’] to retrieve id token from HTTP request

Notes

  • request “idToken” NOT “id_token” from output of HTTP request in appGyver.
  • id tokens expires after 1 hour

Happy developing! :slight_smile:

@Sergio_Invernizzi Sergio_Invernizzi I think you have the same solution.

@DG_L the Authorization section of this Udemy course
https://www.udemy.com/course/firebase-meets-appgyver/ explains how to do this :slight_smile:

1 Like

Hi! I just now published a separate flow function Get ID Token (Firebase Auth) – please check it out!

1 Like