Can't authenticate on page refresh

Hey team, I’m having issues authenticating to 3ID after refresh on mobile browser. I can connect successfully the first time, but when I refresh the page and connect to 3ID again via this function below, it doesn’t go passed the authentication step. I’m testing on Chrome Mobile and IPhone. I’m debugging using Javascript console in Chrome. I don’t see any errors in the log but the code never reaches console.log(“did i reach here”)

I’m not able to add a screen shot but this is the code snippet:

export async function connect3ID(
walletProvider: any,
accounts: string,
ceramicClient: CeramicClient,
setDid: (val: string) => void,
): Promise<{ authProvider: any }> {
const authProvider = new EthereumAuthProvider(walletProvider, accounts);
const threeIdConnect = new ThreeIdConnect(config.THREEID_NETWORK);
await threeIdConnect.connect(authProvider);
const resolver = {
…getResolver(ceramicClient),
};
const did = new DID({ resolver });
ceramicClient.did = did;
try {
const provider = await threeIdConnect.getDidProvider();
ceramicClient.did.setProvider(provider);
} catch (e) {
console.error(“error getting threeId Provider”, e);
}
await ceramicClient.did.authenticate().catch((e) => console.warn(“error authenticating to ceramic”, e));
console.log(“did i reach here”)
setDid(ceramicClient.did.id);
return { authProvider };
}

1 Like

Hi @michael, thanks for your post.

Can you please try putting a try-catch around this line instead of the chained .catch after the call to authenticate()?

await ceramicClient.did.authenticate().catch((e) => console.warn(“error authenticating to ceramic”, e));

That actually work. I can’t tell you how many things I tried. Thanks!!

1 Like

Excellent! Thanks for confirming :grin:

@mohsin,

It seems to work sometime I refresh but then if I refresh again it doesn’t. The 3ID box doesn’t always popup on refresh. Is there anyway we can screen share so you can see the issue i’m having.

Hmm, I actually don’t think I know enough about how the UI piece works to help much :confused:

@zfer, does this problem sound familiar?

The issue is actually evident in your Self.ID app https://self.id/. If you login using IPhone + Chrome, you can connect successfully but if you logout and retry a few times, eventually you will get the same issue. I have a video of me having this issuing with self.id app and I can share if you like. I don’t know where to upload it?

Mind uploading it to Google Drive or Dropbox and sending the link via Discord DM?

I sent the DM with the link and a brief explanation.

would it be possible for you to use did-session instead - Module: did-session | Decentralized Identifiers (DIDs)? this is currently the recommended and most supported auth method now

if you update to the latest version of selfid it will use did-session by default instead of 3id-connect

1 Like

unfortunately for our use case we are using did:3 but did-session uses did:pkh.

what parts/features of did:3 do you want/need that are not supported with did:pkh?