Authorization Code Flow for web applications using MSAL.NET confidential client to sign in users and access APIs on their behalf

MITAuto-check passedBackend & APIs

Install Msal Auth Code Flow

skills CLI
$ npx skills add AzureAD/microsoft-authentication-library-for-dotnet --skill msal-auth-code-flow -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install AzureAD/microsoft-authentication-library-for-dotnet msal-auth-code-flow --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/AzureAD/microsoft-authentication-library-for-dotnet.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.github/skills/msal-auth-code-flow .claude/skills/msal-auth-code-flow && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
msal-auth-code-flow
GitHub stars
1.5k
Token cost
~917 tokens
SKILL.md length
263 words
Files
1
Skills in repo
3
Repo updated
First seen
Licence
MIT

At a glance

Authorization Code Flow for web applications using MSAL.NET confidential client to sign in users and access APIs on their behalf

  • Works in 5 steps: Redirect user to AAD login page → User logs in and consents to permissions → AAD returns authorization code to… → …
  • Tasks that involve OAuth and OpenID Connect
  • SKILL.md covers Overview, When to Use, Flow Steps and Agent Actions
  • Reaches login.microsoftonline.com

What it does

Msal Auth Code Flow is an agent skill from AzureAD/microsoft-authentication-library-for-dotnet. Authorization Code Flow for web applications using MSAL.NET confidential client to sign in users and access APIs on their behalf

Its SKILL.md is about 920 tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Backend & APIs, covering OAuth and OpenID Connect. It works with Microsoft Entra ID and .NET. The repository describes itself as: Microsoft Authentication Library (MSAL) for .NET. The licence is MIT.

When your agent uses it

  • Tasks that involve OAuth and OpenID Connect

Example prompts

  • “/msal-auth-code-flow”

Workflow steps

5 steps, taken from the first numbered list in SKILL.md.

  1. Redirect user to AAD login page
  2. User logs in and consents to permissions
  3. AAD returns authorization code to callback URL
  4. Server exchanges code for token using confidential credentials
  5. Token cached and used to access APIs

What it can do on your machine

Read from SKILL.md and the folder at commit 2d15026. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are csharp).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Hosts in commands or code, which the agent is likely to contact:

    • login.microsoftonline.com

    Also links to:

    • learn.microsoft.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Msal Auth Code Flow loads about 917 tokens when it runs. Until then it costs about 37 tokens; SKILL.md has 263 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~37
When it runs · the whole SKILL.md, loaded when a task matches
~917

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from AzureAD/microsoft-authentication-library-for-dotnet at commit 2d15026, republished under its MIT licence (© AzureAD). 263 words, ~917 tokens.

Download SKILL.mdSave it as .claude/skills/msal-auth-code-flow/SKILL.md (or your agent's skills folder).
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

Authorization Code Flow Skill

Overview

Authorization Code Flow is used by web applications to authenticate users and obtain access tokens on their behalf.

When to Use

  • Web applications with server-side backend
  • Need to access user-scoped APIs
  • User sign-in required
  • Refresh tokens needed

Flow Steps

  1. Redirect user to AAD login page
  2. User logs in and consents to permissions
  3. AAD returns authorization code to callback URL
  4. Server exchanges code for token using confidential credentials
  5. Token cached and used to access APIs

Agent Actions

Generate Code Snippet

Agent can show code snippets for each credential type:

Setup Guidance

Reference appropriate credential setup:

Example: Web Application with Certificate
csharp
// In controller's callback method
[HttpGet("auth/callback")]
public async Task HandleCallback(string code, string state)
{
    // See: with-certificate.cs for credential setup
    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
}
Error Resolution

Refer to Troubleshooting Guide

Best Practices
Explain the Flow
  1. Initiation: Redirect to https://login.microsoftonline.com/{tenant}/oauth2/v2.0/authorize?client_id=...&redirect_uri=...
  2. User Action: User logs in and grants consent
  3. Code Reception: AAD sends authorization code to redirect URI
  4. Token Exchange: Server uses code + client credentials to get token
  5. Token Usage: Token cached and used for API calls
Decision Help

Choose Auth Code Flow if:

  • Building web application with server backend
  • Need to access user resources with user consent
  • Want to maintain long-lived sessions (using refresh tokens)

Avoid if:

  • Building single-page app (use implicit/hybrid instead)
  • Don't have secure backend for credentials

© AzureAD, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .github/skills/msal-auth-code-flow of AzureAD/microsoft-authentication-library-for-dotnet.

Open the folder on GitHubat commit 2d15026

Compare with similar skills

Msal Auth Code Flow next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Msal Auth Code Flow compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Msal Auth Code Flow this skillAzureAD/microsoft-authentication-library-for-dotnet1.5k—~917Automated safety check: PassMIT
Entra Agent Idmicrosoft/GitHub-Copilot-for-Azure2553 repos~4kAutomated safety check: PassMIT
Azure APIM Policy Authoringthomast1906/github-copilot-agent-skills202—~1.5kAutomated safety check: PassMIT
Maui Authenticationdavidortinau/maui-skills174—~1.5kAutomated safety check: PassMIT
Microsoft Azure Webjobs Extensions Authentication Events Dotnetmicrosoft/skills3.1k5 repos~3.8kAutomated safety check: PassMIT
Implementing Google Workspace Sso Configurationmukul975/Anthropic-Cybersecurity-Skills34k—~2kAutomated safety check: PassApache-2.0

Similar skills

  • Entra Agent Id

    microsoft/GitHub-Copilot-for-Azure

    Official

    Provision Microsoft Entra Agent Identity Blueprints, BlueprintPrincipals, and per-instance Agent Identities via Microsoft Graph, and configure OAuth 2.0 token exchange (fmipath, OBO, cross-tenant)…

    255 GitHub starsUsed in 3 repos~4k tokens
    Backend & APIsAuto-check passed
  • Azure APIM Policy Authoring

    thomast1906/github-copilot-agent-skills

    Generates Azure API Management policy XML for authentication, rate limiting, CORS, error handling and transformations, consulting Azure best-practice and documentation tools first.

    202 GitHub stars~1.5k tokensUpdated 2 mo ago
    Backend & APIsAuto-check passed
  • Maui Authentication

    davidortinau/maui-skills

    Add authentication to .NET MAUI apps. An agent skill from davidortinau/maui-skills.

    174 GitHub stars~1.5k tokensUpdated 3 mo ago
    Backend & APIsAuto-check passed
  • Implementing Google Workspace Sso Configuration

    mukul975/Anthropic-Cybersecurity-Skills

    Configures SAML 2.0 single sign-on for Google Workspace against a third-party identity provider (Okta, Azure AD/Entra ID, ADFS), with Workspace as the Service Provider, to centralize authentication…

    34k GitHub stars~2k tokensUpdated 1 mo ago
    Backend & APIsAuto-check passed
  • Entra App Registration

    microsoft/GitHub-Copilot-for-Azure

    Official

    Guides Microsoft Entra ID app registration, OAuth 2.0 authentication, and MSAL integration.

    255 GitHub starsUsed in 2 repos~2.1k tokens
    Backend & APIsAuto-check passed

More from AzureAD/microsoft-authentication-library-for-dotnet

  • Msal Client Credentials

    AzureAD/microsoft-authentication-library-for-dotnet

    Client Credentials Flow for service-to-service (daemon) authentication in MSAL.NET without user involvement

    1.5k GitHub stars~1.1k tokensUpdated today
    Auto-check passed
  • Msal Obo Flow

    AzureAD/microsoft-authentication-library-for-dotnet

    On-Behalf-Of (OBO) Flow for web APIs to call downstream APIs while preserving user identity in MSAL.NET

    1.5k GitHub stars~1.2k tokensUpdated today
    Auto-check passed

Categories

Questions about Msal Auth Code Flow

What does Msal Auth Code Flow do?

Authorization Code Flow for web applications using MSAL.NET confidential client to sign in users and access APIs on their behalf. Msal Auth Code Flow is an agent skill from AzureAD/microsoft-authentication-library-for-dotnet.

When should I use Msal Auth Code Flow?

Msal Auth Code Flow fits situations like: tasks that involve OAuth and OpenID Connect.

How do I install Msal Auth Code Flow in Claude Code?

Run `npx skills add AzureAD/microsoft-authentication-library-for-dotnet --skill msal-auth-code-flow -a claude-code`. Or copy the skill folder (.github/skills/msal-auth-code-flow in AzureAD/microsoft-authentication-library-for-dotnet) into .claude/skills/msal-auth-code-flow in your project. Claude Code loads it when a task matches its description.

How do I install Msal Auth Code Flow in Codex?

Run `npx skills add AzureAD/microsoft-authentication-library-for-dotnet --skill msal-auth-code-flow -a codex`. Or copy the skill folder (.github/skills/msal-auth-code-flow in AzureAD/microsoft-authentication-library-for-dotnet) into .agents/skills/msal-auth-code-flow in your project. Codex loads it when a task matches its description.

Can I use Msal Auth Code Flow in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add AzureAD/microsoft-authentication-library-for-dotnet --skill msal-auth-code-flow -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/msal-auth-code-flow, .gemini/skills/msal-auth-code-flow, .github/skills/msal-auth-code-flow and .opencode/skills/msal-auth-code-flow in your project.

What does Msal Auth Code Flow need to run?

SKILL.md names no scripts, command-line tools or credentials: Msal Auth Code Flow is instructions for the agent only.

Does Msal Auth Code Flow access the network?

SKILL.md names 2 domains. In commands or code: login.microsoftonline.com; the agent is likely to contact it when it follows the instructions. As links in the text: learn.microsoft.com. This is read from the text; nothing was executed.

Is Msal Auth Code Flow safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Msal Auth Code Flow use?

Msal Auth Code Flow is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Msal Auth Code Flow use?

About 917 tokens (SKILL.md is roughly 3.7k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Msal Auth Code Flow?

Skills that share tags, products or a category with Msal Auth Code Flow: Entra Agent Id (microsoft/GitHub-Copilot-for-Azure, 255 stars), Azure APIM Policy Authoring (thomast1906/github-copilot-agent-skills, 202 stars), Maui Authentication (davidortinau/maui-skills, 174 stars) and Microsoft Azure Webjobs Extensions Authentication Events Dotnet (microsoft/skills, 3.1k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Msal Auth Code Flow?

AzureAD (a GitHub organization) maintains it in AzureAD/microsoft-authentication-library-for-dotnet, which has 1,504 GitHub stars. The repository holds 3 skills in this directory. The repository was last updated on October 6, 2026.

Source: AzureAD/microsoft-authentication-library-for-dotnet on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.