Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Firebase getIdToken(true) for refresh token - Refresh token for persistence of user on app is not returning token but error - jsonexception #5996

Closed
shreyasPL opened this issue Oct 14, 2022 · 8 comments · Fixed by #6165
Labels
platform: android type: bug A confirmed bug report

Comments

@shreyasPL
Copy link

Bug Report

Capacitor Version

💊   Capacitor Doctor  💊 

Latest Dependencies:

  @capacitor/cli: 4.3.0
  @capacitor/core: 4.3.0
  @capacitor/android: 4.3.0
  @capacitor/ios: 4.3.0

Installed Dependencies:

  @capacitor/core: 4.3.0
  @capacitor/ios: 4.3.0
  @capacitor/cli: 4.3.0
  @capacitor/android: 4.3.0

[success] iOS looking great! 👌
[success] Android looking great! 👌

Capacitor.config.js

{
  "appId": "our-app.com",
  "appName": "appname",
  "bundledWebRuntime": false,
  "npmClient": "yarn",
  "webDir": "build",
  "plugins": {
    "SplashScreen": {
      "launchShowDuration": 0
    },
    "FirebaseAuthentication": {
      "skipNativeAuth": false,
      "providers": [
        "google.com",
        "facebook.com",
        "apple.com"
      ]
    },
    "CapacitorHttp": {
      "enabled": true
    }
  },
  "server": {
    "androidScheme": "https",
    "iosScheme": "ionic", 
    "cleartext": true,
    "allowNavigation": [
      "*"
    ]
  }
}

Platform(s)

  1. capacitor android only - We are using capacitor.https -> enabled true flag as part of new release 4.3.0 of capcitor.

Current Behavior

  1. We know firebase access token expires after an hour.
  2. We use getIdToken(true) - forcerefresh param to true, for forceful token with extended one hour token.
  3. This function is returning jsonexception error when being called.
  4. FirebaseError/auth-network-failed is returned with no other information.
    NOTE: getIdToken() without param after logging in, returns token perfectly. But with parameter as true it fails all the time.

Expected Behavior

  1. getIdToken(true) should return new token, not the error.

Code Reproduction

const app = getApp();
const auth = getAuth(app);
const updatedUser = auth.currentUser;
updatedUser?.getIdToken(true).then(token => {
     console.log(token, "Forceful"); // doesn't return this
}).catch(err => {
     console.error(err)
});

Other Technical Details

npm --version output: 8.11.0

node --version output: v16.16.0

pod --version output (iOS issues only): nil

Additional Context

firebase: 9.8.2

Please see the image below for the error.
image

Thank you.

@shreyasPL
Copy link
Author

@mlynch
Could you please look into this issue?
I am unable to set the labels.
Thank you.

@harpalsira
Copy link

@mlynch
Hi Max, we would really appreciate this bug being looked at as it's critical that it is fixed before we launch our app. I have reached out to support through other channels but if you could let us know what options we have to expedite this fix, I would be eternally grateful!
best,
Harpal

@jcesarmobile jcesarmobile added the needs reproduction needs reproducible example to illustrate the issue label Oct 27, 2022
@Ionitron
Copy link
Collaborator

This issue may need more information before it can be addressed. In particular, it will need a reliable Code Reproduction that demonstrates the issue.

Please see the Contributing Guide for how to create a Code Reproduction.

Thanks!
Ionitron 💙

@Ionitron Ionitron added the needs reply needs reply from the user label Oct 27, 2022
@harpalsira
Copy link

@Ionitron thank you so much for taking a look. We’ll provide the additional information you have requested asap. Really appreciate the help!

@Ionitron Ionitron removed the needs reply needs reply from the user label Oct 27, 2022
@IbtesamAnsariPL
Copy link

Code Reproduction

Steps:

  1. Clone - https://github.com/IbtesamAnsariPL/pl-test
  2. Run web platform.
  3. Click on Login and then Refresh button -> Works as expected
  4. Run on android platform - npm run android
  5. Click on Login and then Refresh button -> Refresh fails with JSON Exception

@IbtesamAnsariPL
Copy link

@mlynch I have attached the reproduction steps above. Please have a look into it.

@jcesarmobile jcesarmobile added type: bug A confirmed bug report platform: android and removed needs reproduction needs reproducible example to illustrate the issue labels Oct 28, 2022
@shreyasPL

This comment was marked as abuse.

@ionitron-bot
Copy link

ionitron-bot bot commented Feb 11, 2023

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Feb 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
platform: android type: bug A confirmed bug report
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants