Skip to content

Add Agent 365 token support#628

Open
heyitsaamir wants to merge 2 commits into
agent365-featurefrom
agent365-token-support
Open

Add Agent 365 token support#628
heyitsaamir wants to merge 2 commits into
agent365-featurefrom
agent365-token-support

Conversation

@heyitsaamir

@heyitsaamir heyitsaamir commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Adds foundational token support for Agent 365 scenarios:

  • AgenticIdentity type (agenticAppId, agenticUserId, tenantId, agenticAppBlueprintId)
  • agenticBotScope on CloudEnvironment (https://botapi.skype.com/.default)
  • TokenRequestOptions type for extensible token callback options
  • TokenManager.getAgenticToken(agenticIdentity, scope) — 3-step FMI token exchange (T1 → T2 → T3)
  • TokenManager.getAppToken(scope, tenantId?) — generalized app token method
  • TokenCredentials.token signature extended: (scope, tenantId?, options?: TokenRequestOptions)

@heyitsaamir

Copy link
Copy Markdown
Collaborator Author

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds foundational types and plumbing for Agent 365 token scenarios across @microsoft/teams.api and @microsoft/teams.apps, including new agent identity modeling, an extensible token-provider callback shape, and a new TokenManager agentic token acquisition path.

Changes:

  • Introduces AgenticIdentity and exports it from the API models barrel.
  • Extends auth surface area: CloudEnvironment.agenticBotScope and TokenCredentials.token(..., options?: TokenRequestOptions).
  • Updates TokenManager with getAppToken(...) and getAgenticToken(...) plus an @azure/msal-node version bump.

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
packages/apps/src/token-manager.ts Adds getAppToken and implements a 3-step getAgenticToken exchange flow plus new MSAL client caching.
packages/apps/src/token-manager.spec.ts Updates TokenCredentials-provider expectations for the new optional options argument.
packages/apps/package.json Bumps @azure/msal-node dependency version.
packages/api/src/models/index.ts Exports the new agentic-identity model.
packages/api/src/models/agentic-identity.ts Adds the AgenticIdentity type.
packages/api/src/auth/credentials.ts Adds TokenRequestOptions and extends TokenCredentials.token signature to accept options.
packages/api/src/auth/cloud-environment.ts Adds agenticBotScope to CloudEnvironment and populates it for predefined clouds.
package-lock.json Updates lockfile for the MSAL dependency bump.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/apps/src/token-manager.ts
Comment thread packages/apps/src/token-manager.ts
Comment on lines +104 to +108
const confidentialClient = this.getConfidentialClient(this.credentials, tenantId);
const t1Result = await confidentialClient.acquireTokenByClientCredential({
scopes: [TOKEN_EXCHANGE_SCOPE],
fmiPath: agenticIdentity.agenticAppId,
});

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm it should... the latest version of msal should include this.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

False positive — fmiPath is available in @azure/msal-node 5.3.0 (our installed version). It's used in ClientCredentialClient for the FMI exchange step. The Copilot review was checking against outdated type defs.

Comment thread packages/apps/src/token-manager.ts
Comment on lines +83 to +86
async getAgenticToken(
agenticIdentity: AgenticIdentity,
scope: string
): Promise<IToken | null> {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add tests.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree — will add tests for getAgenticToken in a follow-up.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 8 changed files in this pull request and generated 5 comments.

Comment on lines +75 to +76
async getAppToken(scope: string, tenantId?: string, defaultTenantId?: string): Promise<IToken | null> {
return await this.getToken(scope, this.resolveTenantId(tenantId, defaultTenantId ?? this.cloud.loginTenant));
Comment on lines +87 to +94
const tenantId = agenticIdentity.tenantId ?? this.credentials?.tenantId;
if (!tenantId) {
throw new Error('tenantId is required to get an agentic token');
}

if (!this.credentials) {
return null;
}
Comment on lines +262 to +266
const cacheKey = `${tenantId}:${agenticAppId}`;
const cachedClient = this.agentIdentityClientsByTenantAndAppId[cacheKey];
if (cachedClient) {
return cachedClient;
}
Comment thread packages/api/src/auth/credentials.ts Outdated
Comment on lines +83 to +86
async getAgenticToken(
agenticIdentity: AgenticIdentity,
scope: string
): Promise<IToken | null> {
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants