> 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/webxr-sdk/authentication.md).

# Authentication

### 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)](/basics/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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
