Error Invalid Url when redirected from android web app

Error Invalid Url when redirected from android web app.
However it is running on ios web app which is builded from the same code on Capacitor.js

  • SDK Version:
    @web3auth/base”: “^5.2.0”,
    @web3auth/no-modal”: “^5.2.0”,
    @web3auth/openlogin-adapter”: “^5.2.0”,
    @web3modal/standalone”: “^2.4.1”,
  • Platform: Android, Capacitor.js, React.js
  • Browser Console Screenshots:

when redirected external browser

Please provide the Web3Auth initialization and login code snippet below:

const web3auth = new Web3AuthNoModal({
    clientId: API_KEY.WEB3AUTH,
    web3AuthNetwork: "testnet", 
    chainConfig: { chainNamespace: CHAIN_NAMESPACES.OTHER },
  })

  const adapter = new OpenloginAdapter({
    loginSettings: {
      mfaLevel: "none",
    },
    adapterSettings: {
      uxMode: "redirect",
      redirectUrl: dynamiclink,
    },
  })

  web3auth.configureAdapter(adapter)

  await web3auth.init()

  const web3authProvider = await web3auth.connectTo(WALLET_ADAPTERS.OPENLOGIN, { loginProvider })

@samuel Thanks for your recent communication.

Your issue has been forwarded to our team and we will get back with further updates once more information becomes available.

@vjgee
And this is errors before redirected from web app

Have you specified the web3AuthNetwork parameter during the Web3Auth No-Modal initialization ? I’ll paste a snippet here for your reference on where should it go. Please mention the network you are on Testnet, Mainnet, etc whichever you have setup up on the dashboard should match with the network in your code too.

const web3auth = new Web3AuthNoModal({
  clientId: "", // Get your Client ID from Web3Auth Dashboard
  chainConfig: {
    chainNamespace: CHAIN_NAMESPACES.EIP155,
    chainId: "0x1",
    displayName: "Ethereum Mainnet",
    blockExplorer: "https://etherscan.io",
    ticker: "ETH",
    tickerName: "Ethereum",
    rpcTarget: "https://rpc.ankr.com/eth", // This is the mainnet RPC we have added, please pass on your own endpoint while creating an app
  },
  web3AuthNetwork: "mainnet", // mainnet, aqua,  cyan or testnet
});

I’ve modified the code in the body.

Are you still facing any issues?

yes, i am trying to change options, but still facing the same issue

Please use Cyan and check

it has same error,

https://cyan.openlogin.com/start#b64Params=e30&_pid=f1....

when i use ‘testnet’, it is redirected at https://beta.openlogin.com/start#b64Params=e30&_pid=....

but docs say it will be use https://testing.openlogin.com

is it right?

For Web3Auth PnP Web SDKs

If you are using chainNamespace: "other" while initializing or Web3AuthNoModal with the OpenloginAdapter, you need to add the privateKeyProvider to the OpenLogin instance and your rpcTarget in chainconfig

const chainConfig = {
    chainId: "0x1",
    chainNamespace: CHAIN_NAMESPACES.OTHER,
    rpcTarget: "https://any-rpc-endpoint.com",
};

const web3auth = new Web3AuthNoModal({
  clientId,
  chainConfig,
  web3AuthNetwork: "cyan",
});

const privateKeyProvider = new CommonPrivateKeyProvider(config: chainConfig);

const openloginAdapter = new OpenloginAdapter({
  privateKeyProvider,
  adapterSettings: {...},
  mfaSettings: {...},
  loginSettings: {...},
});
web3auth.configureAdapter(openloginAdapter);

provider = await web3auth.connectTo(
  WALLET_ADAPTERS.OPENLOGIN,
  {
    loginProvider: "google",
  }
);

// use this provider to export the private key of the userr

With V6, it’s mandatory to add rpcTarget & chainId in the chainConfig object.

I was able to log in with v6, but redirected url has just sessionId, so I am hard to get login result in capacitor app.

And I am hard to find in docs how to handle this sessionId.

So i am using v5 now, i can get results of redirected base64 code with v5 on iOS.
My codes are working fine on iOS.

@vjgee How can I get a user’s info and privateKey when redirected to the webview app with sessionId using v6 openlogin?

You can refer to this documentation:

I have same issue, but I have this versions:
@web3auth/base”: “^4.2.4”,
@web3auth/core”: “^4.3.2”,
@web3auth/modal”: “^4.3.1”,
@web3auth/openlogin-adapter”: “^4.2.4”,

And set this:
import { WALLET_ADAPTERS, CHAIN_NAMESPACES } from ‘@web3auth/base’;
import { Web3AuthCore } from ‘@web3auth/core’;
import { OpenloginAdapter } from ‘@web3auth/openlogin-adapter’;
import { getAuth0User } from ‘./auth0Api’;

import RPC from ‘./web3RPC’;
import Wallet from ‘…/models/Wallet’;

export const init = async (setWeb3auth, setProvider, setUser, setWallet, setAuth0User, setError, lastVisitedURL) => {
try {
const web3auth = new Web3AuthCore({
clientId: import.meta.env.VITE_APP_WEB_3_CLIENT_ID,
web3AuthNetwork: ‘cyan’,
chainConfig: {
chainNamespace: CHAIN_NAMESPACES.EIP155,
chainId: ‘0x5’,
},
});

const openloginAdapter = new OpenloginAdapter({
  loginSettings: {
    sessionTime: 604800,
  },
  adapterSettings: {
    uxMode: 'redirect',
    loginConfig: {
      jwt: {
        verifier: 'XXXXXX',
        typeOfLogin: 'jwt',
        clientId: 'XXXXXXX',
      },
    },
  },
});

web3auth.configureAdapter(openloginAdapter);
setWeb3auth(web3auth);

openloginAdapter.setAdapterSettings({
  redirectUrl: lastVisitedURL,
});

await web3auth.init();

const initWallet = Wallet;

if (web3auth.provider) {
  setProvider(web3auth.provider);
  const rpc = new RPC(web3auth.provider);
  initWallet.address = await rpc.getAccount();
  setWallet(initWallet);
}

const initUser = await web3auth.getUserInfo();
const auth0User = await getAuth0User(initUser);
// setUser({ ...initUser, name: auth0User.name, profileImage: auth0User.picture });
setUser(initUser);
setAuth0User(auth0User);

} catch (error) {
setError(error);
}
};

export const web3Login = async (web3auth, setProvider, setUser, setWallet, setAuth0User) => {
if (!web3auth) return;

const web3authProvider = await web3auth.connectTo(
WALLET_ADAPTERS.OPENLOGIN,
{
loginSettings: {
sessionTime: 259200,
},
loginProvider: ‘jwt’,
extraLoginOptions: {
verifierIdField: ‘sub’,
domain: import.meta.env.VITE_APP_AUTH0_LOGIN_URL,
},
},
);
setProvider(web3authProvider);

const initWallet = {};
const rpc = new RPC(web3authProvider);
initWallet.address = await rpc.getAccount();
setWallet(initWallet);

const initUser = await web3auth.getUserInfo();
setUser(initUser);

const auth0User = await getAuth0User(initUser);
setAuth0User(auth0User);

return { initWallet, initUser, auth0User };
};

export const web3Logout = async (web3auth, setProvider) => {
if (!web3auth) throw new Error(‘web3auth not initialized yet’);
await web3auth.logout();
setProvider(null);
};

But I have the error:
Issue Web3Auth

@edsongomezc You need to create a different thread for your issue. Do not comment on existing threads.

1 Like

I would advise you to create a new thread so that it can gets all the attention it deserves, this issue is marked as resolved and would close in a while.
By the way, the first thing I see in your package versions is that the versions you are using are outdated. We have released v7 of these SDKs and the @web3auth/core is now @web3auth/no-modal.
Please create a new thread and I’ll be more than happy to help you out.

1 Like