Skip to content

Commit

Permalink
[Extension Service Provider] add option to override access token (#3665)
Browse files Browse the repository at this point in the history
* add option to override access token to support dual tokens
Co-authored-by: Arun George <aruniverse@users.noreply.github.com>
  • Loading branch information
aruniverse authored May 24, 2022
1 parent d8f86ad commit 8b52c5b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions common/api/core-frontend.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -9580,6 +9580,8 @@ export class ServiceExtensionProvider implements ExtensionProvider {

// @alpha
export interface ServiceExtensionProviderProps {
// @internal (undocumented)
getAccessToken?: () => Promise<AccessToken>;
iTwinId: string;
name: string;
version: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@itwin/core-frontend",
"comment": "",
"type": "none"
}
],
"packageName": "@itwin/core-frontend"
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { ExtensionClient, ExtensionMetadata } from "./ExtensionServiceClient";
import type {
ExtensionManifest, ExtensionProvider,
} from "../Extension";
import type { AccessToken } from "@itwin/core-bentley";

/**
* Required props for an extension uploaded to Bentley's Extension Service
Expand All @@ -23,6 +24,8 @@ export interface ServiceExtensionProviderProps {
version: string;
/** iTwin Id */
iTwinId: string;
/** @internal */
getAccessToken?: () => Promise<AccessToken>;
}

/**
Expand Down Expand Up @@ -83,7 +86,7 @@ export class ServiceExtensionProvider implements ExtensionProvider {
private async _getExtensionFiles(props: ServiceExtensionProviderProps) {
const extensionClient = new ExtensionClient();

const accessToken = await IModelApp.authorizationClient?.getAccessToken();
const accessToken = await (props.getAccessToken?.() ?? IModelApp.authorizationClient?.getAccessToken());
if (!accessToken)
return undefined;

Expand Down

0 comments on commit 8b52c5b

Please sign in to comment.