# Invalid Token in JWT.io

**URL:** <https://community.auth0.com/t/invalid-token-in-jwt-io/115823>\
**Category:** Get Help\
**Tags:** auth0-android, sdks-quickstarts\
**Created:** [September 9, 2023, 6:54am UTC](https://community.auth0.com/t/invalid-token-in-jwt-io/115823 "2023-09-09T06:54:50Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![muhannadnaser](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/muhannadnaser/32/50671_2.png) [@muhannadnaser](https://community.auth0.com/u/muhannadnaser)\
**Post date:** [September 9, 2023, 6:54am UTC](https://community.auth0.com/t/invalid-token-in-jwt-io/115823/1 "2023-09-09T06:54:50Z")

</div>

I am using Auth0 with Flutter, I just downloaded the sample, I changed the schema to demo  
so the callback URL is  
demo://ekitabu.eu.auth0.com/android/com.auth0.sample/callback

I am using an audience from an API that I created in the App that uses RS256 encryption algorithm

I was able to login and logout using the sample App.  
but if I take the token to [JWT.io](http://JWT.io) site, it always gives me an invalid signature

The problem is that this App will communicate with another web app so when I send the token to it, it says that the token has invalid signature. and If I take the token from the website header to [JWT.io](http://JWT.io) it can validate the signature there. so there is something wrong with the flutter sample that generates an invalid signature.

anyone can point me to where to look at and if I need to provide more information for some help

Thanks

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [September 11, 2023, 10:10pm UTC](https://community.auth0.com/t/invalid-token-in-jwt-io/115823/3 "2023-09-11T22:10:16Z")

</div>

Hey there @muhannadnaser !

> [@muhannadnaser](#):
>
> I was able to login and logout using the sample App.

That’s good to know! 🙂

It sounds like you might be missing an [audience](https://github.com/auth0/auth0-flutter/blob/main/auth0_flutter/EXAMPLES.md#adding-an-audience) - You can add it like so:

```auto
final credentials = await auth0
    .webAuthentication()
    .login(audience: 'YOUR_AUTH0_API_IDENTIFIER');

```

The following FAQ may be helpful as well:

[https://community.auth0.com/t/what-is-the-audience/71414](https://community.auth0.com/t/what-is-the-audience/71414)

Keep us posted!

---

<div class="post-metadata">

**Author:** ![muhannadnaser](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/muhannadnaser/32/50671_2.png) [@muhannadnaser](https://community.auth0.com/u/muhannadnaser)\
**Post date:** [September 12, 2023, 9:37am UTC](https://community.auth0.com/t/invalid-token-in-jwt-io/115823/4 "2023-09-12T09:37:48Z")

</div>

Thanks for the Reply, I already have an audience in the system, and I am getting the correct token, and When I try to validate the token on [jwt.io](http://jwt.io), the site lists the correct data and values but still the site says that the token has an invalid signature. I made sure that the algorithm being used is RS256 in both the API (used as the audience) and the project that I got the client Id from.

The weird thing is that, we used the APP and API to configure a kotlin project and we got a valid token.

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [September 12, 2023, 8:27pm UTC](https://community.auth0.com/t/invalid-token-in-jwt-io/115823/5 "2023-09-12T20:27:43Z")

</div>

Hey @muhannadnaser no worries, happy to help!

> [@muhannadnaser](#):
>
> I already have an audience in the system, and I am getting the correct token, and When I try to validate the token on [jwt.io](http://jwt.io), the site lists the correct data and values but still the site says that the token has an invalid signature. I made sure that the algorithm being used is RS256 in both the API (used as the audience) and the project that I got the client Id from.

Thanks for confirming!

> [@muhannadnaser](#):
>
> The weird thing is that, we used the APP and API to configure a kotlin project and we got a valid token.

That is very weird - I just tested using the Flutter sample and am getting a token back with a valid signature 🤔 This is all I am doing:

```auto
Future<void> login() async {
    try {
      if (kIsWeb) {
        return auth0Web.loginWithRedirect(redirectUrl: 'http://localhost:3000');
      }

      var credentials = await auth0
          .webAuthentication(scheme: dotenv.env['AUTH0_CUSTOM_SCHEME'])
          .login(audience: dotenv.env['AUTH0_AUDIENCE']);

      setState(() {
        _user = credentials.user;
        print(credentials.accessToken);
      });
    } catch (e) {
      print(e);
    }
  }

```

Sounds silly, but it might be worth just deleting/re-downloading the sample and starting from scratch. Unfortunately it seems like there could be a misconfiguration somewhere in the sample app specifically given the client id and API identifier are working elsewhere 😕

Keep us posted!

---

<div class="post-metadata">

**Author:** ![muhannadnaser](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/muhannadnaser/32/50671_2.png) [@muhannadnaser](https://community.auth0.com/u/muhannadnaser)\
**Post date:** [September 13, 2023, 2:12pm UTC](https://community.auth0.com/t/invalid-token-in-jwt-io/115823/6 "2023-09-13T14:12:38Z")

</div>

Thanks for the reply, I have confirmed something, when I use the default audience, I get a valid token with minimum info in the audience. but when I try using any of my APIs identifier as audience to get a more meaningful JWT token, the token becomes invalid.

is there any relation between the App and the audience, what I understand, if multiple apps wants to use the same token, like a mobile and a web connected to the same backend, then I will have two APPs (native and web) but they are connected to the same API (audience) and this is what I am trying to achieve.

Thanks for the help

---

<div class="post-metadata">

**Author:** ![muhannadnaser](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/muhannadnaser/32/50671_2.png) [@muhannadnaser](https://community.auth0.com/u/muhannadnaser)\
**Post date:** [September 14, 2023, 7:32am UTC](https://community.auth0.com/t/invalid-token-in-jwt-io/115823/7 "2023-09-14T07:32:28Z")

</div>

Thanks for the help, it really was a silly problem but it took me more than 3 days and the support from Auth0 to figure it out.  
it is a limitation from Flutter, the print function only prints up to 1024 character, so when I use a simple audience and the token is small, then it will be valid because the print function will print the full token. But when I use a more complicated audience to include more data, the token becomes more than 1024 characters and the print function will truncate it without saying anything so the token becomes invalid

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [September 14, 2023, 10:46pm UTC](https://community.auth0.com/t/invalid-token-in-jwt-io/115823/8 "2023-09-14T22:46:01Z")

</div>

Ahhh @muhannadnaser wow, good to know! That’s a tricky one 😬 Hopefully this helps others using Flutter in the future though!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [September 28, 2023, 10:46pm UTC](https://community.auth0.com/t/invalid-token-in-jwt-io/115823/9 "2023-09-28T22:46:30Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
