> For AI agents: the complete documentation index is available at /core-sdk/map/web/llms.txt, the full documentation bundle is available at /core-sdk/map/web/llms-full.txt.

# External Token Injection

Register Mapxus map by the specified token by `setTokenProvider()` of `@mapxus/mapxus-auth`.
**Call Signature**

```js
TTokenProvider: () => Promise<{
    accessToken: string;
    expiresAt: number;
    identifier: string;
}>;
```

**Example**

```js
import {setTokenProvider} from "@mapxus/mapxus-auth";
import {Map as MaplibreMap} from "maplibre-gl";
import {Map} from "@mapxus/mapxus-map";

const tokenProvider = async () => {
	// Your logic to get token
    return Promise.resolve({
	    accessToken: "your_token",
	    expiresAt: {token_expiration_timestamp},
        identifier: "your_identifier"
    });
}
// Register by token provider
setTokenProvider(tokenProvider);

// Call Mapxus products
const maplibreMap = new MaplibreMap({
    container: "map",
    zoom: 18,
});
const map = new Map({
    map: maplibreMap,
    floorId: "2cdd6174730d4431b1aa730eda596ed4"
});

globalThis.MapxusMapEvents.on("initError", error => {
	console.log(error.message);
});

globalThis.MapxusMapEvents.on("unauthorized", () => {
	// Handle unauthorized event
});
```
