How to get SSO SAML token using C# from Azure Active Directory

Sigusmund 0 Reputation points
2024-07-10T15:46:35.85+00:00

Hi everyone,

Just a quick question.

Is it possible using C# to authenticate an account in Azure Active Directory and retrieve an SAML token back? If so, how can we go about doing this?

Many thanks

Active Directory
Active Directory
A set of directory-based technologies included in Windows Server.
6,671 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,039 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,934 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 67,016 Reputation points
    2024-07-10T22:05:23.8566667+00:00

    a SAML token is an identity token. You need to use a browser to get an id token via the auth code or implicit flow. Currently azure ad supports using a webview for the browser, but other oauth providers are requiring a native browser. see the msal library:

    https://learn.microsoft.com/en-us/entra/identity-platform/msal-overview

    you can use password (your tenant must be configure to support this), or client credential (clientid, client secret) flow to get an access token (jwt) without using a browser.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.