6. Microsoft Graph is all about you
If you or your customers are part of the millions of users that are using Microsoft
cloud services, then Microsoft Graph is the fabric of all your data
It all starts with /me
7. Gateway to your data in the Microsoft
cloud
Your app
Gateway
Your or your
customer’s
data
Office 365 Windows 10 Enterprise Mobility + Security
1Microsoft Graph
9. Microsoft 365 Platform
web, device,
and service apps
Extend Microsoft 365 experiences
1
iOS/Android/Windows/Web
Build your experience
Microsoft Graph
12. Exploring the Graph
• Using the Graph Explorer
• Using plain HTTP Calls
• Using .NET
• Using PnP PowerShell
• Using JavaScript (Browser or Node)
• Using the SDKs
13.
14. 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Connecting to your tenant
Connect-PnPOnline -Graph -LaunchBrowser
# Getting the appropriate scoped
Connect-PnPOnline –Scopes @("Mail.Send", "User.Read.All")
# Build the Headers with the Access Token value
$headers = @{
"Authorization" = [String]::Format("Bearer {0}", (Get-PnPAccessToken));
"Content-Type" = "application/json"
}
# Calling the Microsoft Graph
Invoke-RestMethod -Header $headers -Uri "https://graph.microsoft.com/v1.0/me"
Get-Contacts.ps1
20. 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Building an Email JSON representation
$EmailBody = @{
"Message" = @{
"Subject" = "This is a test email from PowerShell!" ;
"Body" = @{
"ContentType" = "HTML" ;
"Content" = "This email was sent from PowerShell with the Microsoft Graph.";
} ;
"ToRecipients" = @(
@{
"EmailAddress" = @{
"Address" = "admin@sebastienlevert.onmicrosoft.com"
}
}
)
}
}
Invoke-RestMethod -Header $headers –Uri "https://graph.microsoft.com/v1.0/me/sendMail" -
Method Post -Body ($EmailBody | ConvertTo-Json -Depth 4)
Send-Email.ps1
21. 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// Requiring the Microsoft Graph SDK
const MicrosoftGraph = require("../../lib/src/index.js").Client;
// Getting the Access Token from a secret file
const secrets = require("./secrets");
// Initializing the Microsoft Graph SDK
const client = MicrosoftGraph.init({
defaultVersion: 'v1.0’,
debugLogging: true,
authProvider: (done) => {
done(null, secrets.accessToken);
}
});
send-email.js
22. 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// Building the Email Message
const mail = {
subject: "This is a test email from NodeJS!",
toRecipients: [{
emailAddress: {
address: "admin@slevert.onmicrosoft.com"
}
}],
body: {
content: "This email was sent from NodeJS using the Microsoft Graph.",
contentType: "html"
}
}
// Email from the Microsoft Graph
client.api("/users/me/sendMail").post({message: mail}, (err, res) => {
if (err) console.log(err);
else console.log("Sent an email");
});
send-email.js
33. Graph & SharePoint
• SPFx supports the MSGraphClient to
simplify the authentication
• SPFx supports the AadHttpClient for
custom LOB applications
• Caution : Permissions are global to your
tenant for regularWebParts.
• Isolated WebParts have single
permissions (Preview in 1.7)
39. Share your experience
• Use hashtags to share your experience
• #Office365Dev
• #MicrosoftGraph
• Log issues & questions to the GitHub Repositories