The authClient.getIdentity() method returns a DelegationIdentity (which extends a SignIdentity) if the login process has been completed successfully.
So, you just need to cast the type:
_identity = authClient.getIdentity() as DelegationIdentity; // or: as SignIdentity
Can you please detail here the configuration of your local environment (what command did you use to run the WS Gateway, what URL are you connecting to from the frontend, etc.)?
If you can provide these details, I can better help you!
It looks like there’s something wrong with the identity passed to the IC WebSocket class. I’m investigating it, since there seems to be an issue with the ic-websockets-chat-mo example too.
In the meantime, can you also provide a snippet of the code that you’re using on the frontend to authenticate the user and open the WebSocket connection?
Here, you’re authenticating using the Internet Identity mainnet canister. This creates a DelegatedIdentity signed by the mainnet canister, and that’s why the local replica cannot verify the signature.
The solution is to deploy a local instance of the Internet Identity (docs) and authenticate a user from your frontend using that instance. Then, after deploying the Internet Identity canister locally, you have to change the following line:
You may want to control this value through an environment variable like DFX_NETWORK. We did something similar here.
Let me know if it works!
Just a side note: When you deploy to mainnet, I think you don’t need the #authorize suffix in the identityProvider link. Just https://identity.ic0.app/ should work.