PnP Core SDK - WPF Sample
This solution demonstrates how the PnP Core SDK can be used in a WPF application
Source code
You can find the sample source code here: /samples/Demo.WPF
Run the sample
Register and configure an AAD app
In order for the user to authenticate on the App, A new app registration should be created on Azure Portal
In App registrations, click New registration
Enter a name for your new app, make sure Accounts in this organizational directory only is selected. As the Redirect URI, in the Mobile and desktop applications platform enter http://localhost (only needed if you want use an interactive authentication flow)
Under Implicit grant section, check ID tokens and Access tokens
Under Advanced settings section, set Allow public client flows to yes
Go to API permissions section , click Add a permission
- Select Microsoft Graph > Delegated permissions > select Directory.Read.All
- Select Microsoft Graph > Delegated permissions > select User.Read
- Select Microsoft Graph > Delegated permissions > select ChannelMessage.Read.All
- Select Microsoft Graph > Delegated permissions > select ChannelMessage.Send
- Select Microsoft Graph > Delegated permissions > select TeamSettings.ReadWrite.All
- Select Microsoft Graph > Delegated permissions > select TeamsTab.ReadWrite.All
Click Grant admin consent for {tenant}
From Overview, -- copy the value of Directory (tenant) ID -- copy the value of Application (client) ID
Configure your application
The application can be used with different authentication providers, see https://pnp.github.io/pnpcore/articles/consumer/configuring%20authentication.html for more details on the options.
In this the sample uses an interactive flow, so you need to:
- Configure the Tenant ID of your app as the value of
PnPCore:Credentials:InteractiveFlow:TenantId
in appsettings.json setting - Configure the Client ID of your app as the value of
PnPCore:Credentials:InteractiveFlow:ClientId
in appsettings.json setting - Configure the URL of a target Microsoft SharePoint Online modern team site collection as the value of
PnPCore:Credentials:Sites:DemoSite:SiteUrl
in appsettings.json setting
Be sure to have a Team in Microsoft Teams backing the modern team site in the above site collection
Execute
Hit F5 in Visual studio to execute the WPF app. When clicking on one of the buttons to load data, the applications prompts you for signing in via your browser.