一键导入
msal-auth-code-flow
Authorization Code Flow for web applications using MSAL.NET confidential client to sign in users and access APIs on their behalf
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Authorization Code Flow for web applications using MSAL.NET confidential client to sign in users and access APIs on their behalf
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | msal-auth-code-flow |
| description | Authorization Code Flow for web applications using MSAL.NET confidential client to sign in users and access APIs on their behalf |
| tags | ["msal","auth-code","authorization-code","web-app","confidential-client","user-sign-in","redirect","consent"] |
| source | https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/blob/main/.github/skills/msal-auth-code-flow/SKILL.md |
Authorization Code Flow is used by web applications to authenticate users and obtain access tokens on their behalf.
// In controller's callback method
[HttpGet("auth/callback")]
public async Task HandleCallback(string code, string state)
{
var app = ConfidentialClientApplicationBuilder
.Create(clientId)
.WithCertificate(cert)
.WithAuthority($"https://login.microsoftonline.com/{tenantId}/v2.0")
.WithRedirectUri("https://myapp.com/auth/callback")
.Build();
var result = await app.AcquireTokenByAuthorizationCode(
new[] { "scope-uri" },
code)
.ExecuteAsync();
// Result contains AccessToken, RefreshToken, ExpiresOn
}
msal-shared/references/token-caching-strategies.md) for optimal token acquisitionmsal-cache-handling skillAddMicrosoftIdentityWebAppAuthentication() which handles the auth code flow automaticallyRejectSessionCookieWhenAccountNotInCacheEvents validates on every requestSignOutAsync() in ValidatePrincipal — this creates an auth redirect loop; call context.RejectPrincipal() onlyChoose Auth Code Flow if:
Avoid if:
Handle MSAL distributed token cache collisions and stale entries in ASP.NET Core applications
On-Behalf-Of (OBO) Flow for web APIs to call downstream APIs while preserving user identity in MSAL.NET
{what this skill teaches agents}
Review API DTO implementations for contract/domain separation, mapping patterns, and REST compliance
This skill should be used when the user asks to "build a feature", "fix a bug", "implement something", "start a dev cycle", types "/dev", or describes a software task that requires design, implementation, testing, and shipping. Orchestrates the full software development lifecycle from interrogation through shipping, with self-learning that improves over time.
Frontend JavaScript patterns for event handling, form UX, and validation integration