Calling ICP canister from non-ICP backend with authentication

I want to call an ICP canister with authentication from a non-ICP backend (javascript)

how do i pass on my authentication? preferable with example code
its server side, along these lines

const identity = ?????;
const agent = new HttpAgent(identity);
const auth_backend = Actor.createActor(idlFactory, { agent, canisterId });
console.log(await auth_backend.doSomething());

Hi @richards,

I’m not entirely sure what you want to do, but if you want to create an identity server-side and call a canister then here’s a tutorial to do that:

1 Like

our scenario:
a non-ICP webserver is handing out tokens if a user does something in that system,
so users provides some information and gets X loyalty coins

i want to call something like "grantTokens(toPrinciple:x, amount y) from my non-ICP server to my coin canister

i need to be sure that these calls originate from the given non_ICP webserver - through identity or certificate or something

practical would be if i can provide some signed identity along with my call from the non-icp server

That’s exactly the scenario that can be tackled with the tutorial above.

You initialize an identity in the web server from a given private key or seed and then check that the caller is the corresponding principal in the canister.

1 Like