How to get auth token by user email and password?

asdfasfawfwfwf 45 Reputation points
2024-04-23T15:30:49.4666667+00:00

I want to hit calendar events API in an external app. i.e. https://graph.microsoft.com/v1.0/users/{user-id}/events
I have created a new app in Azure AD. Then I got hold of client id, client secret and tenant id. I have my Microsoft email and password.
To hit calendar events API, I need auth token. Is there a way to hit Auth API such that I provide it with client id, client secret, tenant id, user email, password though javascript so that it directly give me auth token in response without asking for user email, password, authenticator passcode to the user on front end.____

Microsoft 365 and Office | Development | Office JavaScript API
Outlook | Windows | Classic Outlook for Windows | For business
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,960 questions
Microsoft Security | Microsoft Authenticator
Microsoft Security | Microsoft Graph
{count} votes

Accepted answer
  1. Vahid Ghafarpour 23,385 Reputation points Volunteer Moderator
    2024-04-23T19:06:09.37+00:00

    Thanks for posting your question in the Microsoft Q&A forum.

    You can achieve this by using the OAuth 2.0 client credentials flow in Azure AD. This flow allows your application (acting as a confidential client) to obtain an access token directly using its own credentials (client ID and client secret), without involving a user.

    https://learn.microsoft.com/en-us/entra/identity-platform/v2-oauth2-client-creds-grant-flow#get-a-token

    ** Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful **

    0 comments No comments

0 additional answers

Sort by: Most helpful

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.