Using the Candid UI when an identity is required

I have many functions in my canister operate on the logged-in user by way of the msg.caller property, for example a function like this:

public shared(msg) func getUserName() : Text {
  return getProfile(msg.caller).name;
}

But when I try to test this function in the auto-generated candid interface, it always uses the anonymous user so I can never test that it’s actually able to find and operate on specific users.

Is it possible to spoof a user in the candid UI so I can test these functions?

5 Likes

Not out of the box, but maybe that’s something @chenyan wants to add? Could be a cool feature and I think @PaulLiu even implemented “login” via pem file for tipjar :thinking:

There is a community project test.icscan.io you can login (via plug) to call canister interface.

Welcome external contribution to add II in Candid UI :slight_smile:

Another option is to use ic-repl's identity command. It has auto-completion based on Candid types, feels like a textual version of Candid UI.

1 Like

Have there been any new developments on this question since April?

For a local deployment ic-repl seems to be the only option.

The latest on this is that there’s a library, @dfinity/candid-ui, which provides a web component you can accept an identity while providing the base candid UI experience. Check out the docs at

And see this example for how to authenticate the candid UI component: billowing-snow-l6sp1g - CodeSandbox

You can use it locally for testing, or you can embed it inside your dapp to give your users easy ability to interact with arbitrary canisters using their already authenticated identity in your site

3 Likes

Thanks.
I’m having another auth issue here: Error logging icrc1 token name in frontend

The code is here: candid/tools/ui at master · dfinity/candid · GitHub

1 Like