> For the complete documentation index, see [llms.txt](https://docs.multiset.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.multiset.ai/web-sdk/webxr-sdk/authentication.md).

# Authentication

Get credentials and authorize the Multiset client before starting a session

### Get Your Credentials

Open the [Multiset Developer Portal](https://developer.multiset.ai) and navigate to the **Credentials** section. Copy your **Client ID** and **Client Secret**.

Your **Map Code** or **Map Set Code** is listed in the Maps section of the portal (format: `MAP_XXXXXXXXXX`).

### Authorize the Client

Create a `MultisetClient` and call `authorize()` before starting an AR session. Authorization exchanges your credentials for a short-lived access token used in all subsequent API calls.

```typescript
import { MultisetClient } from '@multisetai/vps/core';

const client = new MultisetClient({
  clientId: 'YOUR_CLIENT_ID',
  clientSecret: 'YOUR_CLIENT_SECRET',
  mapType: 'map',       // 'map', 'map-set', or 'object-tracking'
  code: 'MAP_XXXXXXXXXX',
});

await client.authorize();
```

For a **MapSet**, change `mapType` to `'map-set'` and pass the map set code:

```typescript
const client = new MultisetClient({
  clientId: 'YOUR_CLIENT_ID',
  clientSecret: 'YOUR_CLIENT_SECRET',
  mapType: 'map-set',
  code: 'MAPSET_XXXXXXXXXX',
});
```

{% hint style="warning" %}
Call `authorize()` once before any localization or tracking request. If the token expires during a long session, call it again to refresh.
{% endhint %}

### CORS Configuration

Localization requests are made directly from the browser to the Multiset API. Your domain must be added to the allowlist or every request will fail with a CORS error.

Follow the steps in [Configuring Allowed Domains (CORS)](/fundamentals/credentials/configuring-allowed-domains-cors.md) before going to production.

{% hint style="info" %}
`localhost` and `127.0.0.1` are allowed by default for development.
{% endhint %}

### Environment Variables

Avoid hardcoding credentials in source code. Use environment variables and load them at build time:

```typescript
const client = new MultisetClient({
  clientId: import.meta.env.VITE_MULTISET_CLIENT_ID,
  clientSecret: import.meta.env.VITE_MULTISET_CLIENT_SECRET,
  mapType: 'map',
  code: import.meta.env.VITE_MAP_CODE,
});
```

{% hint style="warning" %}
Client credentials are visible to anyone who inspects your bundle. For production apps, proxy the `authorize()` call through your own backend and return only the token to the browser.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.multiset.ai/web-sdk/webxr-sdk/authentication.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
