# Importing identity to javascript with private key

**URL:** <https://forum.dfinity.org/t/importing-identity-to-javascript-with-private-key/7701>\
**Category:** Developers\
**Created:** [October 5, 2021, 9:17am UTC](https://forum.dfinity.org/t/importing-identity-to-javascript-with-private-key/7701 "2021-10-05T09:17:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kevinli](https://avatars.discourse-cdn.com/v4/letter/k/8edcca/32.png) [@kevinli](https://forum.dfinity.org/u/kevinli)\
**Post date:** [October 5, 2021, 9:17am UTC](https://forum.dfinity.org/t/importing-identity-to-javascript-with-private-key/7701/1 "2021-10-05T09:17:45Z")

</div>

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

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

```

I have the private key of the identity. Can I import that and create an Identity object or something?

---

<div class="post-metadata">

**Author:** ![3cL1p5e7](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/3cl1p5e7/32/4649_2.png) [@3cL1p5e7](https://forum.dfinity.org/u/3cL1p5e7)\
**Post date:** [October 6, 2021, 7:31pm UTC](https://forum.dfinity.org/t/importing-identity-to-javascript-with-private-key/7701/2 "2021-10-06T19:31:18Z")

</div>

Unfortunately, I have no information about importing keys.  
But you can login through Internet Identity canister and pass `identity` to `HttpAgent` to make user-authorized call.  
And you need to deploy internet identity canister to local replica

> **[GitHub - dfinity/internet-identity: Internet Identity, a blockchain...](https://github.com/dfinity/internet-identity)**
>
> Internet Identity, a blockchain authentication system for the Internet Computer - GitHub - dfinity/internet-identity: Internet Identity, a blockchain authentication system for the Internet Computer
