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, and this page is available as Markdown at /core-sdk/map/web/v10/01-getting-started/06-external-token-injection.md.
MapxusDeveloper Platform
Products
Positioning APIAccess real-time indoor coordinates and contextual signals.API
UI SDKProduction-ready indoor map interfaces and UI components.AndroidiOS

External Token Injection

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

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

Example

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
});