Fetching Azure AD details of Members when signing using Clerk

Sudhakar J 0 Reputation points
2024-04-30T12:31:29.94+00:00

Hi, I am building an app using NextJS, Clerk for authentication, Prisma as ORM, postgres as DB. I want to sign in using Azure/Entra AD as I'm building an app for my company and I want to fetch the details of users when they sign in using clerk and how do I proceed with this?

User's image

Once the user signin, I get their details in Clerk Dashboard
User's image

User's image

Now how can I get the user's details from the Azure AD itself like their full name, role, id and so on?

Active Directory
Active Directory
A set of directory-based technologies included in Windows Server.
5,958 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,761 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Akhilesh 5,175 Reputation points Microsoft Vendor
    2024-05-02T12:34:07.64+00:00

    Hi @Sudhakar J

    Thank you for reaching out to the community forum!

    You can retrieve user details from Entra ID (Azure AD) using the Microsoft Graph API, Microsoft Graph API is a web API that enables you to access Microsoft Cloud service resources.

    follow the bellow steps to achieve your ask.

    1. Register your application in Entra ID and get the client ID and client secret and set the permissions for Microsoft Graph to allow the app to read user profiles.
    2. Configure Clerk to use Entra ID as an identity provider for authentication and set up the necessary redirect URIs and token configuration.
    3. Once the user is authenticated, you can use the access token provided by Entra ID to call Microsoft Graph API and get the user's details. This token can be used to authorize requests to the Microsoft Graph API

    Reference: https://learn.microsoft.com/en-us/entra/architecture/authenticate-applications-and-users

    https://learn.microsoft.com/en-us/entra/external-id/identity-providers

    Hope this helps. Do let us know if you any further queries.

    Thanks.

    Akhilesh.


    If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.