---
title: "Client API: Setting up Authentication and Authorization"
url: "https://docs.ravendb.net/6.2/client-api/setting-up-authentication-and-authorization"
version: "6.2"
language: "nodejs"
---

# Client API: Setting up Authentication and Authorization

> Client language: Node.js. Also available for [C#](https://docs.ravendb.net/6.2/client-api/setting-up-authentication-and-authorization.md), [Java](https://docs.ravendb.net/6.2/client-api/setting-up-authentication-and-authorization.java.md).
>
> RavenDB publishes an official agent skill for coding assistants at https://docs.ravendb.net/skills/ravendb/SKILL.md (also installable with `npx skills add ravendb/skills`). The skill describes itself as: "Read this before writing any RavenDB query, client call or /databases/ request. Covers server setup, document modelling, the Node.js, .NET and Python clients, RQL, indexes, vector search and AI agents. Code written from recall tends to run and return the wrong rows, because RQL resembles SQL and the clients take field names as plain strings."

Authentication and authorization is based on [client X.509 certificates](https://docs.ravendb.net/6.2/server/security/authorization/security-clearance-and-permissions.md).

The authentication options argument in `DocumentStore` constructor property allows you to pass a certificate which will be used by the RavenDB client to connect to a server.

> **Note**
>
> If your RavenDB server instance is served using `https`, then your application is required to use a client certificate in order to be able to access the server. You can find more information [here](https://docs.ravendb.net/6.2/server/security/overview.md).

## Example

```javascript
import { DocumentStore } from "ravendb";
import * as fs from "fs";

// load certificate and prepare authentication options
const authOptions = {
  certificate: fs.readFileSync("C:\\ravendb\\client-cert.pfx"),
  type: "pfx", // or "pem"
  password: "my passphrase"
};

const store = new DocumentStore([ "https://my_secured_raven" ], "Northwind", authOptions);
store.initialize();

// proceed with your work here
```

## See also

- [Installation : Setup Wizard Walkthrough](https://docs.ravendb.net/6.2/start/installation/setup-wizard/overview.md)
- [What is a Document Store](https://docs.ravendb.net/6.2/client-api/what-is-a-document-store.nodejs.md)
- [Creating a Document Store](https://docs.ravendb.net/6.2/client-api/creating-document-store.nodejs.md)
- [Setting up Default Database](https://docs.ravendb.net/6.2/client-api/setting-up-default-database.nodejs.md)
- [Security Overview](https://docs.ravendb.net/6.2/server/security/overview.md)
- [Security Clearance &amp; Permissions](https://docs.ravendb.net/6.2/server/security/authorization/security-clearance-and-permissions.md)
- [Client Certificiate Usage](https://docs.ravendb.net/6.2/server/security/authentication/client-certificate-usage.md)
- [Certificate Management](https://docs.ravendb.net/6.2/server/security/authentication/certificate-management.md)
