Search code examples
azurevalidationoauth-2.0azure-active-directory

Can i fetch user profile by using client_id and client_secret of Azure Oauth app?


I have requirement where i have to store client_id and client_secret in database, before storing in database i have to validate given client_id and client_secret, If i am able to fetch username by client_id and client_secret than i can compare user given username and username from Microsoft if both are matching than i am good to store in database.

Note : I can fetch userprofile by using access_token but this is not i am looking for.


Solution

  • Yes, It is possible to fetch user profile using client_id and client_secret using application only permissions. To achieve this you need to use Client credential flow and MS Graph.

    Since,

    1. The client credential flow does not require User login.
    2. MS Graph supports Application permissions for the user. Please refer MS Document.

    Please go through the Github sample which can help to achieve the same.