# \[Archive\] User not found exception on Android devices

**URL:** <https://builder.metamask.io/t/archive-user-not-found-exception-on-android-devices/1782>\
**Category:** Embedded Wallets (Web3Auth)\
**Created:** [September 21, 2023, 9:06am UTC](https://builder.metamask.io/t/archive-user-not-found-exception-on-android-devices/1782 "2023-09-21T09:06:40Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![harishiv](https://avatars.discourse-cdn.com/v4/letter/h/4da419/32.png) [@harishiv](https://builder.metamask.io/u/harishiv)\
**Post date:** [September 21, 2023, 9:06am UTC](https://builder.metamask.io/t/archive-user-not-found-exception-on-android-devices/1782/1 "2023-09-21T09:06:40Z")

</div>

> **🏛 Archived Content from Web3Auth Community**
> 
> This topic was originally posted by **harishiv** on 9/21/2023.  
> This content has been migrated from our previous community forum to preserve valuable discussions.

* * *

**Please provide the following details too when asking for help in this category:**

- SDK Version: `web3auth_flutter: ^2.0.3` and `web3dart: ^2.4.1`
- Related to Custom Authentication? Please provide the following info too: **(Optional)**
  - Verifier Name: toad-cash-verifier
  - Sample idToken(JWT) from TorusUserInfo class : `eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IlRZT2dnXy01RU9FYmxhWS1WVlJZcVZhREFncHRuZktWNDUzNU1aUEMwdzAifQ.eyJpYXQiOjE2OTQ0OTkxMDQsImF1ZCI6IkJJLWxxcGFHWllDRW1CRkota09JQ0xDUXNidXd1U1hJcXlONUdQazhOMjdIMG5pM2E4VzA4a1dyRGF6LWRybWRhNjZpbUtPVFFwMHZPSlNmWkJFaDJnSSIsIm5vbmNlIjoiMDNkOGFjOTVjNTJkOWRjMWNhNzIxN2IwMzk2MzQ2YzVhODk1NzcxOTUxZTAzYTZiYWY4Nzc4YTFkZDliMDc4YzYxIiwiaXNzIjoiaHR0cHM6Ly9hcGktYXV0aC53ZWIzYXV0aC5pbyIsIndhbGxldHMiOlt7InB1YmxpY19rZXkiOiIwMmY1ZmY5MGFiNDM1NTQ5YzQzOWQyYTE4NTdlOGE2ZDYxNDRkNDI2OWQ5NDQ4NzRlM2JlYzQ5YWIzODE0MDgyOWEiLCJ0eXBlIjoid2ViM2F1dGhfYXBwX2tleSIsImN1cnZlIjoic2VjcDI1NmsxIn1dLCJlbWFpbCI6ImhhcmlzaGl2QHJvdmVyeC50ZWFtIiwibmFtZSI6IkhhcmlzaGl2IFNpbmdoIiwicHJvZmlsZUltYWdlIjoiaHR0cHM6Ly9saDMuZ29vZ2xldXNlcmNvbnRlbnQuY29tL2EvQUFjSFR0ZUhHaGlFTnRyRDFNcWtJQy1GYzRhbWwwLW1FckUtZFZMdmJXVEtIUnJtPXM5Ni1jIiwidmVyaWZpZXIiOiJ0b2FkLXRlc3QtdmVyaWZpZXIiLCJ2ZXJpZmllcklkIjoiNmN3WDRMUzNFaWVldnByZEI4eDVHamY3ekdNMiIsImFnZ3JlZ2F0ZVZlcmlmaWVyIjoidG9hZC10ZXN0LXZlcmlmaWVyIiwiZXhwIjoxNjk0NTg1NTA0fQ.MQmzN-TpTeYovKs5CHa7yzAoXtigZ1R5fGpomoI_zPXZdE4i-F-B_lTt4BUQx5WisTV0xXoHaI83WctLfq0koQ`

**Please provide the Web3Auth initialization and login code snippet below:**

Initialisation:

```auto
  Future<void> _initPlatformState() async {
    final themeMap = HashMap<String, String>();
    themeMap['primary'] = "#F5820D";
Uri redirectUrl;
if (Platform.isAndroid) {
  redirectUrl = Uri.parse('w3a://com.example.app/auth');
} else if (Platform.isIOS) {
  redirectUrl = Uri.parse('com.example.app://openlogin');
} else {
  throw UnKnownException('Unknown platform');
}

final loginConfig = HashMap&lt;String, LoginConfigItem&gt;();
loginConfig['jwt'] = LoginConfigItem(
  verifier: "toad-test-verifier", // get it from web3auth dashboard
  typeOfLogin: TypeOfLogin.jwt,
  name: "Custom JWT Login",
  clientId: dotenv.env['WEB3AUTH_CLIENT_ID'],
);

await Web3AuthFlutter.init(
  Web3AuthOptions(
    clientId: dotenv.env['WEB3AUTH_CLIENT_ID'] ?? '',
    network: Network.testnet,
    redirectUrl: redirectUrl,
    whiteLabel: WhiteLabelData(
      dark: true,
      name: "Toad Cash",
      theme: themeMap,
    ),
    loginConfig: loginConfig,
  ),
);

```

Login code:

```auto
  VoidCallback _login(Future<Web3AuthResponse> Function() method) {
    return () async {
      context.showProgressBar();
      try {
        final Web3AuthResponse response = await method();
        SharedPreference.setPrivateKey(response.privKey.toString());
        SharedPreference.setIdToken(
            response.userInfo?.idToken.toString() ?? '');
        UserDetails userDetails = UserDetails(
            name: response.userInfo?.name,
            email: response.userInfo?.email,
            profileImage: response.userInfo?.profileImage);
        _proceedToSuccessScreen(userDetails);
      } on UserCancelledException {
        context.dismissProgressBar();
        print("User cancelled.");
      } on UnKnownException {
        context.dismissProgressBar();
        print("Unknown exception occurred");
      }
    };
  }
Future<Web3AuthResponse> _googleSignInWithJWT() async {
var idToken = await _getFirebaseIdTokenFromGoogleSignIn();
return Web3AuthFlutter.login(
  LoginParams(
    loginProvider: Provider.jwt,
    mfaLevel: MFALevel.NONE,
    extraLoginOptions: ExtraLoginOptions(
      id_token: idToken,
      domain: 'https://toad.cash',
    ),
  ),
);

}
Future<String> _getFirebaseIdTokenFromGoogleSignIn() async {
var idToken = “”;
try {
final GoogleSignInAccount? result = await GoogleSignIn().signIn();
final GoogleSignInAuthentication? googleAuth =
await result?.authentication;
final credential = GoogleAuthProvider.credential(
accessToken: googleAuth?.accessToken,
idToken: googleAuth?.idToken,
);
final userCredential =
await FirebaseAuth.instance.signInWithCredential(credential);
  idToken = (await userCredential.user?.getIdToken(true)).toString();
} on FirebaseAuthException catch (e) {
  if (e.code == 'user-not-found') {
    print('No user found for that email.');
  } else if (e.code == 'wrong-password') {
    print('Wrong password provided for that user.');
  }
}
return idToken;

```

For the first login, I am getting the idToken successfully but when I restart the application it gives me a PlatformException for User not found.

---

<div class="post-metadata">

**Author:** ![vjgee](https://avatars.discourse-cdn.com/v4/letter/v/b5e925/32.png) [@vjgee](https://builder.metamask.io/u/vjgee)\
**Post date:** [September 21, 2023, 9:24am UTC](https://builder.metamask.io/t/archive-user-not-found-exception-on-android-devices/1782/2 "2023-09-21T09:24:50Z")

</div>

@harishiv Thanks for reaching out.

Your issue has been forwarded to our team and we will get back once there is a meaningful update to share.

---

<div class="post-metadata">

**Author:** ![gaurav](https://avatars.discourse-cdn.com/v4/letter/g/b487fb/32.png) [@gaurav](https://builder.metamask.io/u/gaurav)\
**Post date:** [September 21, 2023, 9:35am UTC](https://builder.metamask.io/t/archive-user-not-found-exception-on-android-devices/1782/3 "2023-09-21T09:35:40Z")

</div>

Hi @harishiv, can you list down all steps you are doing?

---

<div class="post-metadata">

**Author:** ![harishiv](https://avatars.discourse-cdn.com/v4/letter/h/4da419/32.png) [@harishiv](https://builder.metamask.io/u/harishiv)\
**Post date:** [September 21, 2023, 10:19am UTC](https://builder.metamask.io/t/archive-user-not-found-exception-on-android-devices/1782/4 "2023-09-21T10:19:50Z")

</div>

Hi @gaurav,

I followed the following steps:

1. Generated idToken using FirebaseAuth
2. Used the above idToken to login into Web3Auth using `Web3AuthFlutter.login`
3. After successful login, fetched the idToken from userInfo (`Web3AuthFlutter.getUserInfo()`)

This complete flow works fine for the first time, but when I close the app restart it again, the idTokn from `Web3AuthFlutter.getUserInfo()` gives me an exception of User not found. The exact exception is mentioned below:

> PlatformException(error, java.lang.Error: No user found, please login again!, java.lang.Error: No user found, please login again!, null)

And the whole flow is working as expected in iOS, but this issue is only happening in android.

---

<div class="post-metadata">

**Author:** ![gaurav](https://avatars.discourse-cdn.com/v4/letter/g/b487fb/32.png) [@gaurav](https://builder.metamask.io/u/gaurav)\
**Post date:** [September 21, 2023, 10:36am UTC](https://builder.metamask.io/t/archive-user-not-found-exception-on-android-devices/1782/5 "2023-09-21T10:36:51Z")

</div>

@harishiv Have you tried running example app with sdk, that’s working fine. Pls check code with that.

---

<div class="post-metadata">

**Author:** ![harishiv](https://avatars.discourse-cdn.com/v4/letter/h/4da419/32.png) [@harishiv](https://builder.metamask.io/u/harishiv)\
**Post date:** [September 21, 2023, 11:12am UTC](https://builder.metamask.io/t/archive-user-not-found-exception-on-android-devices/1782/6 "2023-09-21T11:12:49Z")

</div>

I tried to run the application but there it was giving me an error of `adb: failed to install /Users/StudioProjects/web3auth-pnp-examples/flutter/flutter-firebase-example/build/app/outputs/flutter-apk/app-debug.apk: Failure [INSTALL_FAILED_USER_RESTRICTED: Invalid apk]`

I compared the code, and it’s similar to mine.

---

<div class="post-metadata">

**Author:** ![harishiv](https://avatars.discourse-cdn.com/v4/letter/h/4da419/32.png) [@harishiv](https://builder.metamask.io/u/harishiv)\
**Post date:** [September 21, 2023, 11:43am UTC](https://builder.metamask.io/t/archive-user-not-found-exception-on-android-devices/1782/7 "2023-09-21T11:43:42Z")

</div>

I was able to run the application in one your examples ([https://github.com/Web3Auth/web3auth-pnp-examples/tree/main/flutter/flutter-example](https://github.com/Web3Auth/web3auth-pnp-examples/tree/main/flutter/flutter-example)), but there as well as soon as I close the app and relaunch it once again. It asks me to login again.

The user needs to login on every single launch.

---

<div class="post-metadata">

**Author:** ![gaurav](https://avatars.discourse-cdn.com/v4/letter/g/b487fb/32.png) [@gaurav](https://builder.metamask.io/u/gaurav)\
**Post date:** [September 21, 2023, 3:54pm UTC](https://builder.metamask.io/t/archive-user-not-found-exception-on-android-devices/1782/8 "2023-09-21T15:54:11Z")

</div>

I am talking about the example attached with sdk repo itself i.e. [https://github.com/Web3Auth/web3auth-flutter-sdk/tree/master/example](https://github.com/Web3Auth/web3auth-flutter-sdk/tree/master/example)
