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?

Windows for business | Windows Client for IT Pros | Directory services | Active Directory
Microsoft Security | Microsoft Entra | Microsoft Entra ID
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Akhilesh Vallamkonda 15,320 Reputation points Microsoft External Staff Moderator
    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.


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.