Microsoft Graph API : Do we need to be logged in to make an Graph API call ?

Abhay Chandramouli 971 Reputation points
2022-05-09T06:20:00.067+00:00

Hi,
I am trying to make a Microsoft Graph api call using a SPA React JS application. Do I need to be logged in to make an api call like say /users/{id} ? I used the msal sdk and it feels it requires an accesstoken to make api calls.

I am trying to achieve a scenario where I try to login and check if the username exists, if it does I capture the password and update it. Else I create a new user. This is similar to Seamless Account Migration setup.

  1. I want the user to click on login
  2. He enters his username and password. ( This is him logging in first time after migration)
  3. If his migration status is false, I capture the password and save it, and set mig status as true.
  4. then he gets logged in

So for this, I need to make an MS Graph API Call before the user is logged in. So for that I am facing issues.

Please help

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,364 questions
Microsoft Entra External ID
Microsoft Entra External ID
A modern identity solution for securing access to customer, citizen and partner-facing apps and services. It is the converged platform of Azure AD External Identities B2B and B2C. Replaces Azure Active Directory External Identities.
2,759 questions
0 comments No comments
{count} votes

Accepted answer
  1. Zehui Yao_MSFT 5,846 Reputation points
    2022-05-09T08:09:34.547+00:00

    Helloanonymous user, before you call the Microsoft Graph API , you need acquire an access token from the Microsoft identity platform as stated in the documentation.
    You can Install the Microsoft Graph SDK to authorization and API calls in Javascript.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful