Archived Content from Web3Auth Community
This topic was originally posted by githubdiscussions on 12/15/2022.
This content has been migrated from our previous community forum to preserve valuable discussions.
I was following this guide.
web3auth.connectTo throws an error Failed to connect with wallet. Failed to login with openlogin, indeed it seems like it does work successfully on UX redirect.
My code is following:
blockExplorer: ‘https://etherscan.io/’,
ticker: ‘ETH’,
tickerName: ‘Ethereum’,
},
});
const openloginAdapter = new OpenloginAdapter({
adapterSettings: {
clientId,
network: ‘testnet’,
uxMode: ‘popup’,
loginConfig: {
jwt: {
name: ‘…’,
verifier: verifierId,
typeOfLogin: ‘jwt’,
clientId: firebaseAppId,
},
},
},
});
web3auth.configureAdapter(openloginAdapter);
export const getWeb3AuthWallet = async (idToken: string) => {
await web3auth.init();
try {
await web3auth.connectTo(WALLET_ADAPTERS.OPENLOGIN, {
loginProvider: ‘jwt’,
extraLoginOptions: {
id_token: idToken,
verifierIdField: ‘sub’,
domain: ‘http://localhost:3000’,
},
});
} catch (e) {
debugger;
console.error(e);
}
const accounts = await web3auth.provider?.request({ method: ‘eth_requestAccounts’ });
console.log(accounts);
debugger;
// const web3 = new Web3(web3auth.provider as any);
// const userAccounts = await web3.eth.getAccounts();
// const [address] = userAccounts;
};
">
import Web3 from ‘web3’;
import { Web3AuthCore } from ‘@web3auth/core’;
import { CHAIN_NAMESPACES, WALLET_ADAPTERS } from ‘@web3auth/base’;
import { OpenloginAdapter } from ‘@web3auth/openlogin-adapter’;const clientId =
‘…’;const verifierId = ‘…’;
const firebaseAppId = ‘…’;
const web3auth = new Web3AuthCore({
clientId,
chainConfig: {
chainNamespace: CHAIN_NAMESPACES.EIP155,
chainId: ‘0x1’,
rpcTarget: ‘https://mainnet.infura.io/v3/776218ac4734478c90191dde8cae483c’,
blockExplorer: ‘https://etherscan.io/’,
ticker: ‘ETH’,
tickerName: ‘Ethereum’,
},
});const openloginAdapter = new OpenloginAdapter({
adapterSettings: {
clientId,
network: ‘testnet’,
uxMode: ‘popup’,
loginConfig: {
jwt: {
name: ‘…’,
verifier: verifierId,
typeOfLogin: ‘jwt’,
clientId: firebaseAppId,
},
},
},
});web3auth.configureAdapter(openloginAdapter);
export const getWeb3AuthWallet = async (idToken: string) => {
await web3auth.init();try {
await web3auth.connectTo(WALLET_ADAPTERS.OPENLOGIN, {
loginProvider: ‘jwt’,
extraLoginOptions: {
id_token: idToken,
verifierIdField: ‘sub’,
domain: ‘http://localhost:3000’,
},
});
} catch (e) {
debugger;
console.error(e);
}const accounts = await web3auth.provider?.request({ method: ‘eth_requestAccounts’ });
console.log(accounts);
debugger;
// const web3 = new Web3(web3auth.provider as any);
// const userAccounts = await web3.eth.getAccounts();
// const [address] = userAccounts;
};
Originally posted by: urgn
Check the discussion at: https://github.com/orgs/Web3Auth/discussions/1083