title | description | services | documentationcenter | author | manager | editor | ms.service | ms.devlang | ms.topic | ms.tgt_pltfrm | ms.workload | ms.date | ms.author | ms.custom |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
include file |
include file |
active-directory |
dev-center-name |
jmprieur |
mtillman |
active-directory |
na |
include |
na |
identity |
09/17/2018 |
jmprieur |
include file |
To run your project, in Visual Studio, select F5. Your application MainWindow is displayed, as shown here:
The first time that you run the application and select the Call Microsoft Graph API button, you're prompted to sign in. Use an Azure Active Directory account (work or school account) or a Microsoft account (live.com, outlook.com) to test it.
The first time that you sign in to your application, you're also prompted to provide consent to allow the application to access your profile and sign you in, as shown here:
After you sign in, you should see the user profile information that's returned by the call to the Microsoft Graph API. The results are displayed in the API Call Results box. Basic information about the token that was acquired via the call to AcquireTokenAsync
or AcquireTokenSilentAsync
should be visible in the Token Info box. The results contain the following properties:
Property | Format | Description |
---|---|---|
Name | User's full name | The user’s first and last name. |
Username | [email protected] | The username that is used to identify the user. |
Token Expires | DateTime | The time at which the token expires. MSAL extends the expiration date by renewing the token as necessary. |
Access Token | String | The token string that is sent to HTTP requests that require an Authorization header. |
The Microsoft Graph API requires the user.read scope to read a user's profile. This scope is automatically added by default in every application that's registered in the Application Registration Portal. Other APIs for Microsoft Graph, as well as custom APIs for your back-end server, might require additional scopes. The Microsoft Graph API requires the Calendars.Read scope to list the user’s calendars.
To access the user’s calendars in the context of an application, add the Calendars.Read delegated permission to the application registration information. Then, add the Calendars.Read scope to the acquireTokenSilent
call.
Note
The user might be prompted for additional consents as you increase the number of scopes.
[!INCLUDE Help and support]