mgt logged in user

Christophe Humbert 101 Reputation points
2021-02-12T20:39:38.423+00:00

I am using the Login component of the Microsoft graph Toolkit (React flavor). How can I retrieve the display name and UPN of the logged in user?

I see that the component has a loginCompleted prop, but the user is not passed as argument.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,296 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Deva-MSFT 2,256 Reputation points Microsoft Employee
    2021-02-14T05:53:30.95+00:00

    You may want to try the following; adding the code:

    import React, {
      useRef,
      useEffect,
    } from 'react';
    
    import {Login} from '@microsoft/mgt-react';
    
    
    const Login = () => {
    
      return (
        <div className="login">
          <Login loginCompleted={(e) => console.log('Logged in')} />
        </div>
      );
    };
    
    0 comments No comments