Ionic with React and google auth: idToken is truncated in android

Issue

I’m using Ionic with React and @codetrix-studio’s capacitor-google-auth plugin to enable google auth. The processed idToken has different lengths when comparing Web to Android environments.

When running in the web browser I’m getting 1224 chars and everything works just fine. But when running android I’m only getting 1122 chars. Also I’m not getting anything out of the accessToken.

Can anyone provide some hits on how to solve this?

I’m getting the token like so:

async signIn(): Promise<void> {
  const result: any = await Plugins.GoogleAuth.signIn();

  if (result) {
    let token = result.authentication.idToken;
    this.setToastMsg(token.length + "");
  }
}

This is triggered from a simple button:

<IonButton onClick={() => this.signIn2()} >Login with Google</IonButton>

Solution

Turns out the token provided by google for the android api is actually smaller. So everything is ok.

Answered By – Luís Silva

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published