my dapp ask you t log in with an internet identity to use some of the features. My anchor device is my phone. i use the same anchor for my computer.
when i logged in to my dapp with my anchor device, it worked as intended. then i went to my computer and logged in the same dapp it lauched internet identity, i chose my anchor but the notification never came,
is this intentional, it would be annoying for users to only be logged in from one device at a time. Since my dapp is mainly streaming and reading website.
to fix this i just deleted the cookies cached in my anchor device
hi @valiantlynx,
When trying out your app, I cannot initiate a login. I see the following message, but no pop-up or prompt appear:
I remember some people mentioning that “some” agent-js
version had a bug where it would only ever open Internet Identity in a pop-up, which are blocked in many browsers. @kpeacock or @Severin can you comment on that?
so far the only way i know to implement internet identity is always a pop up. it actually has quite a bit of annoying issues.
Do you mean to tell me theres a way where i dont need the popup?
yes to log in to my dapp you have to give permision for pop up. so it is always blocked at first it an issue thats why i have the message in the login.
This is one of the bigger issue. there are some more, It might be hoe im implementing my code. ill share the file for you
these are my dependencies for the app
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"@dfinity/auth-client": "^0.13.2",
"@dfinity/authentication": "^0.13.2",
"@dfinity/identity": "^0.13.2",
"lit-html": "^1.4.1",
"ts-loader": "^9.2.3",
"typescript": "^4.3.5"
}
this is my code fro the first page. it pops up the internet identity
import ReactDOM from 'react-dom/client'
import React from 'react'
import App from "./components/App";
import { AuthClient } from '@dfinity/auth-client';
import { Actor, HttpAgent } from "@dfinity/agent";
const init = async () => {
const authClient = await AuthClient.create();
// //must remove before deploying live
// const localHost = "http://localhost:8081/";
// const agent = new HttpAgent({host: localHost});
// agent.fetchRootKey();
const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(<h1 class="login">
To login to your wallet you need an "Internet Identity"
<br />
<br />
If a pop up window does not appear please "allow popup window" and refresh the site.
</h1>);
// handleAuthenticated(authClient);
//is already logged in within 8 days
if (authClient.isAuthenticated() && ((await authClient.getIdentity().getPrincipal().isAnonymous()) === false)) {
//console.log("logged in");
handleAuthenticated(authClient);
} else {
//log in
await authClient.login({
identityProvider: "https://identity.ic0.app/#authorize",
onSuccess: () => {
handleAuthenticated(authClient);
}
});
}
}
async function handleAuthenticated(authClient) {
//console.log(authClient.getIdentity());
const identity = await authClient.getIdentity();
const userPrincipal = identity.getPrincipal().toString();
//console.log(userPrincipal);
const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(<App loggedInPrincipal={userPrincipal} />);
}
init();
Its checks if your logged in, if you are it renders the page. if not it pop up the internet identity
Which version of agent-js are you using?
im not sure how to check or answer that
"dependencies": {
"@dfinity/auth-client": "^0.13.2",
"@dfinity/authentication": "^0.13.2",
"@dfinity/identity": "^0.13.2",
}
You are using v0.13.2
. Can you upgrade to v0.13.3
?
There was a desktop popup issue in agent-js v0.13.0/1/2
that was solved in v0.13.3. Might be the issue you are facing?
ok. done and deployed.
Did it did the trick ?
it didnt really do anything. the window still pops up. is there a specific way i have to write the code
?
@valiantlynx did you run npm update @dfinity/auth-client ...
after bumping the dependency in the package.json?
i.e. does the lockfile show the correct version?
no i just changed the package,json and rum npm install
ill try your suggestion
unfortunately the popup is still there
yes it does show the correct version
from lockfile
"dependencies": {
"@dfinity/auth-client": "^0.13.3",
"@dfinity/authentication": "^0.13.3",
"@dfinity/identity": "^0.13.3",
Your app is open source?
Note the package-lock.json
should contains something as following:
"node_modules/@dfinity/auth-client": {
"version": "0.13.3",
"resolved": "https://registry.npmjs.org/@dfinity/auth-client/-/auth-client-0.13.3.tgz",
yes here it is
"node_modules/@dfinity/auth-client": {
"version": "0.13.3",
"resolved": "https://registry.npmjs.org/@dfinity/auth-client/-/auth-client-0.13.3.tgz",
"integrity": "sha512-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxZqQ==",
"dependencies": {
"@types/jest": "^28.1.4",
"idb": "^7.0.2",
"jest": "^28.1.2",
"ts-jest": "^28.0.5",
"ts-node": "^10.8.2"
},
"peerDependencies": {
"@dfinity/agent": "^0.13.3",
"@dfinity/authentication": "^0.13.3",
"@dfinity/identity": "^0.13.3",
"@dfinity/principal": "^0.13.3"
}
},
Should be good indeed, thanks for double checking, appreciated.
So, your app is open source?
Do you have a link we can test?
i have this (https://5ilw3-6iaaa-aaaak-acxbq-cai.ic0.app/)` if thats what you mean. I didnt know it was open source
well its a token wallet with a token smartcontract writen in motoko as the backend.
@valiantlynx based on the screen @nmattia showed above, I think you are trying to call login
“automatically”, which isn’t a supported flow for window.open
in most browsers. Instead of routing to a new page, could you try using a button
that runs authClient.login
during the onClick
event?
wouldn’t that still just create a window upon clicking?