Hi @Freya
Ok, now I think I got it right.
It seems to me that the error is that when “logging in” with the refresh_token, it does not return the data in the same way as when logging in with email and password.
In the case of the login with email and password, it returns this data with this structure:
{
"localId": "ZY1rJK0eYLg...",
"email": "[user@example.com]",
"displayName": "",
"idToken": "[ID_TOKEN]",
"registered": true,
"refreshToken": "[REFRESH_TOKEN]",
"expiresIn": "3600"
}
But when “logging in” with the refresh_token, it gives us this data and with this structure
{
"expires_in": "3600",
"token_type": "Bearer",
"refresh_token": "[REFRESH_TOKEN]",
"id_token": "[ID_TOKEN]",
"user_id": "tRcfmLH7o2XrNELi...",
"project_id": "1234567890"
}
In the second case, it does not return the email, so you will not be able to get it this way.
The option you mentioned seems valid to me, that is, discard the login page in case of a positive check with the refresh_token.
If you want to continue working on what you were doing, you can try the “Get user data” option.
For this option you would first have to use the refresh_token and then with the new id_token you got use an “HTTP request” to get the user data including email.
As a first step you would have to use an “HTTP request” with the refresh_token as explained by @vereggen in his “STEP 2”.
That way, among other things, you get a new id_token and with that data you create a new json variable with this format:
{"idToken":"[FIREBASE_ID_TOKEN]"}
Then, with a new “HTTP request”, it passes in the “Request body” the variable that you created in the previous step and returns the following information:
{
"users": [
{
"localId": "ZY1rJK0...",
"email": "user@example.com",
"emailVerified": false,
"displayName": "John Doe",
"providerUserInfo": [
{
"providerId": "password",
"displayName": "John Doe",
"photoUrl": "http://localhost:8080/img1234567890/photo.png",
"federatedId": "user@example.com",
"email": "user@example.com",
"rawId": "user@example.com",
"screenName": "user@example.com"
}
],
"photoUrl": "https://lh5.googleusercontent.com/.../photo.jpg",
"passwordHash": "...",
"passwordUpdatedAt": 1.484124177E12,
"validSince": "1484124177",
"disabled": false,
"lastLoginAt": "1484628946000",
"createdAt": "1484124142000",
"customAuth": false
}
]
}
In this link you have more information
Hope this can help you.
Greetings.