Using internet identity in a script

Okay so I’m writing a script to call certain functions of a canister that require me to have certain permissions (caller must be a certain principal).

const canisterId = "rrkah-fqaaa-aaaaa-aaaaq-cai";
const host = "http://localhost:8000/";
    const agent = new HttpAgent({ host });
    const actor = Actor.createActor(someIDL, {
      canisterId: canisterId,
    await (actor as any).callFunctionThatOnlyOwnerCanAccess();

How do I authorize myself from the script and make the call? Or would it be better to just try and make a command line script do the same thing so I can use dfx cli?

Pass identity to HttpAgent

You can use Internet Identity canister to make login and get identity.
Check this repo

1 Like