Skip to content

Commit 05e3cfd

Browse files
authored
Fix preview style can not get token in the hosted version (#10)
* fix preview style can not get token in the hosted version
1 parent b150fe3 commit 05e3cfd

2 files changed

Lines changed: 3 additions & 6 deletions

File tree

src/tools/create-token-tool/CreateTokenTool.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ export class CreateTokenTool extends MapboxApiBasedTool<
2020
input: CreateTokenInput,
2121
accessToken?: string
2222
): Promise<{ type: 'text'; text: string }> {
23-
if (!accessToken) {
24-
throw new Error('MAPBOX_ACCESS_TOKEN is not set');
25-
}
26-
2723
const username = MapboxApiBasedTool.getUserNameFromToken(accessToken);
2824

2925
this.log(

src/tools/preview-style-tool/PreviewStyleTool.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ export class PreviewStyleTool extends MapboxApiBasedTool<
1717
}
1818

1919
protected async execute(
20-
input: PreviewStyleInput
20+
input: PreviewStyleInput,
21+
accessToken?: string
2122
): Promise<{ type: 'text'; text: string }> {
22-
const username = MapboxApiBasedTool.getUserNameFromToken();
23+
const username = MapboxApiBasedTool.getUserNameFromToken(accessToken);
2324

2425
// Get list of tokens to find a public token
2526
const listTokensTool = new ListTokensTool();

0 commit comments

Comments
 (0)