Not getting oAuthAccessToken, oAuthIdToken on Flutter SDK when using Auth0

When asking for help in this category, please make sure to provide the following details:

  • SDK Version: 3.1.0
  • Platform: Android
  • Browser Console Screenshots:
  • If the issue is related to Custom Authentication, please include the following information (optional):
    • Verifier Name: googel_provider
    • JWKS Endpoint:
    • Sample idToken (JWT):

Also, kindly provide the Web3Auth initialization and login code snippet below. This will help us better understand your issue and provide you with the necessary assistance.

HashMap themeMap = HashMap<String, String>();
    themeMap['primary'] = "#229954";

    Uri redirectUrl;
    if (Platform.isAndroid) {
      redirectUrl = Uri.parse(_androidRedirectUrl);
    } else if (Platform.isIOS) {
      redirectUrl = Uri.parse(_iosRedirectUrl);
    } else {
      throw UnKnownException('Unknown platform');
    }

    HashMap<String, LoginConfigItem> loginConfig =
    new HashMap<String, LoginConfigItem>();
    loginConfig["jwt"] = LoginConfigItem(
        verifier: "googel_provider",
        typeOfLogin: TypeOfLogin.jwt,
        clientId: _auth0ClientId);

    await Web3AuthFlutter.init(Web3AuthOptions(
        clientId:
        _web3ClientId,
        redirectUrl: redirectUrl,
        network: Network.testnet,
        loginConfig: loginConfig,
        whiteLabel:
        WhiteLabelData(mode:ThemeModes.dark, appName: "Social PayMe", theme: themeMap)));
    await Web3AuthFlutter.initialize();

 Future<Web3AuthResponse> withProvider() {
    return Web3AuthFlutter.login(LoginParams(
        loginProvider: Provider.google,
        extraLoginOptions: ExtraLoginOptions(
          domain: _authDomain,
          verifierIdField: "Sub",
        ),
        mfaLevel: MFALevel.DEFAULT));
  }

 @override
  Future<bool> signIn({Map<String, dynamic> parameters=const {}}) async{
    try {
      final Web3AuthResponse response = await (parameters[Parameters.method.name] as Future<Web3AuthResponse> Function())();
      credentials = response.userInfo;
      Logger.log(_tag, "token after sign in: ${credentials?.oAuthIdToken}");
      Logger.log(_tag, "token after sign in: ${credentials?.oAuthAccessToken}");
      Logger.log(_tag, "token after sign in: ${credentials?.idToken}");
      return true;
    } on UserCancelledException {
      Logger.log(_tag, "User cancelled.");
      return false;
    } on UnKnownException {
      Logger.log(_tag, "Unknown exception occurred");
      return false;
    }
  }

I want to get jwt token and use it for api call, but not geeting oAuthAccessToken, oAuthIdToken which help me get jwt token and refresh jwt token from Auth APIs

@shridhar.c Thanks for your patience.

Your issue has been forwarded to our Dev team and we will get back with further updates.

oAuthAccessToken & oAuthIdToken are returned only in case of custom authentication.

Is this the verifier you created on the Web3Auth Dashboard? Which network?

For Auth0 logins, it should be Provider.jwt.

For reference, please take a look at this example:

I have set up the custom authentication only. With Auth0 verifier

Yes, this is verifier created on the Testnet network

This was on me. Im only intend for users to log in through Google. Now they have to navigate through two screens to do that when I select provider.jwt. I just want to eliminate the middle step for the user, where they don’t need to click on “Continue with Google” and then log in. How to eliminate this step?

Also, I was receiving an Opeque token; I intended to get jwt token for api calls. How can we achive that?

Both of these problems were solved in the same way we solved them on Auth0. We need to pass additional parameters as shown in the below code.

Web3AuthFlutter.login(LoginParams(
        loginProvider: Provider.jwt,
        extraLoginOptions: ExtraLoginOptions(
          domain: "https://"+_authDomain,
          verifierIdField: "sub",
          audience: _audience,// API audience
          additionalParams: {
      'connection': 'google-oauth2',
      "prompt": 'select_account'
    }
        ),
        mfaLevel: MFALevel.DEFAULT));

By adding audience, you get JWT token, and by adding additionalParams as given you enable only google account login.

Note: only for custom authentication

I’m glad to know this worked for you.

I believe passing the connection directly to extraLoginOptions will also skip the additional prompt.

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