@microsoft/teams.apps
Version:
<p> <a href="https://www.npmjs.com/package/@microsoft/teams.apps" target="_blank"> <img src="https://img.shields.io/npm/v/@microsoft/teams.apps/latest" /> </a> <a href="https://www.npmjs.com/package/@microsoft/teams.apps?activeTab=code
55 lines (54 loc) • 2.96 kB
TypeScript
import { CloudEnvironment, IToken, ITokenProvider } from '@microsoft/teams.api';
import { TokenManager } from './token-manager';
/**
* The app's own token source, backed by the credentials the `App` was
* configured with. Reach it as `app.tokenProvider` to acquire a token for
* something the SDK does not call for you, such as an OpenTelemetry exporter.
*
* Unlike a consumer-supplied {@link ITokenProvider}, every capability is
* implemented, so the agentic methods are required rather than optional.
*/
export interface IAppTokenProvider extends ITokenProvider {
/**
* Acquires an app-only (service-to-service) token.
*
* @param scope the scope to request the token for. Defaults to the configured
* cloud environment's bot scope.
* @param tenantId the tenant to acquire the token in. Defaults to the tenant
* configured on the app's credentials.
* @returns the token, or `null` when the app has no credentials configured.
*/
getAppToken(scope?: string, tenantId?: string): Promise<IToken | null>;
/**
* Acquires a token carrying the requested user-backed agentic identity.
*
* @param scope the scope to request the token for. Defaults to the configured
* cloud environment's agentic Bot API scope when `undefined`.
* @param agenticAppId the agentic app ID that owns the user.
* @param agenticUserId the agentic user ID to act as.
* @param tenantId the tenant to acquire the token in. Defaults to the tenant
* configured on the app's credentials.
* @returns the token, or `null` when the app has no credentials configured.
*/
getAgenticUserToken(scope: string | undefined, agenticAppId: string, agenticUserId: string, tenantId?: string): Promise<IToken | null>;
/**
* Acquires a token carrying the requested app-backed agentic identity.
*
* @param scope the scope to request the token for. Defaults to the configured
* cloud environment's agentic Bot API scope when `undefined`.
* @param agenticAppId the agentic app ID to act as.
* @param tenantId the tenant to acquire the token in. Defaults to the tenant
* configured on the app's credentials.
* @returns the token, or `null` when the app has no credentials configured.
*/
getAgenticAppToken(scope: string | undefined, agenticAppId: string, tenantId?: string): Promise<IToken | null>;
}
/** @internal */
export declare class AppTokenProvider implements IAppTokenProvider {
private readonly tokenManager;
private readonly cloud;
constructor(tokenManager: TokenManager, cloud?: CloudEnvironment);
getAppToken(scope?: string, tenantId?: string): Promise<IToken | null>;
getAgenticUserToken(scope: string | undefined, agenticAppId: string, agenticUserId: string, tenantId?: string): Promise<IToken | null>;
getAgenticAppToken(scope: string | undefined, agenticAppId: string, tenantId?: string): Promise<IToken | null>;
}