# Calling canister on main network needs no authentication

**URL:** <https://forum.dfinity.org/t/calling-canister-on-main-network-needs-no-authentication/11208>\
**Category:** Developers\
**Created:** [March 1, 2022, 10:38am UTC](https://forum.dfinity.org/t/calling-canister-on-main-network-needs-no-authentication/11208 "2022-03-01T10:38:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shashika](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/shashika/32/4622_2.png) [@shashika](https://forum.dfinity.org/u/shashika)\
**Post date:** [March 1, 2022, 10:38am UTC](https://forum.dfinity.org/t/calling-canister-on-main-network-needs-no-authentication/11208/1 "2022-03-01T10:38:22Z")

</div>

I deployed my canisters to the main network. I could access those canisters through the Nodejs client without using any key(Principle id). Is there a way to restrict access to the canister?

---

<div class="post-metadata">

**Author:** ![Ori](https://avatars.discourse-cdn.com/v4/letter/o/ecae2f/32.png) [@Ori](https://forum.dfinity.org/u/Ori)\
**Post date:** [March 1, 2022, 11:19am UTC](https://forum.dfinity.org/t/calling-canister-on-main-network-needs-no-authentication/11208/2 "2022-03-01T11:19:04Z")

</div>

You can check the caller’s principal in your public methods using msg.caller, as described here: [https://smartcontracts.org/docs/language-guide/caller-id.html](https://smartcontracts.org/docs/language-guide/caller-id.html)

Eg:

```auto
public shared(msg) func hello() {
    if (msg.caller == allowedPrincipal) {
	...

```

A few more examples are linked here too:  
[https://forum.dfinity.org/t/which-is-the-best-way-to-set-admin-to-your-application/1621/2?u=ori](https://forum.dfinity.org/t/which-is-the-best-way-to-set-admin-to-your-application/1621/2)

---

<div class="post-metadata">

**Author:** ![shashika](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/shashika/32/4622_2.png) [@shashika](https://forum.dfinity.org/u/shashika)\
**Post date:** [March 2, 2022, 4:00am UTC](https://forum.dfinity.org/t/calling-canister-on-main-network-needs-no-authentication/11208/3 "2022-03-02T04:00:38Z")

</div>

Thanks for the reply @Ori. But when we are testing canisters locally we have to fetch the identity from the root key. right? otherwise, we cannot access the canister on the local node.  
Why is that?  
Why is that not applying for the main network?
