Getting Started with Microsoft Graph and JavaScript SDKs

Microsoft 365 Developer · Beginner ·🧠 Large Language Models ·7y ago

Key Takeaways

The video demonstrates how to get started with Microsoft Graph and JavaScript SDKs, including handling authentication tokens, status codes, and SDK sample code. It covers the benefits of using the SDK, such as standard error handling and batch requests, and provides a step-by-step guide on how to integrate the SDK into an existing application.

Full Transcript

everyone I'm Gerry here with Daryl today how are you doing good mate we're gonna be talking about the JavaScript SDK today so as a JavaScript developer or web developer in general why would someone use that the Microsoft got SDKs so with our SDKs we allow you what we help you do a lot of kind of standard behavior when working with the graph handling standard error codes doing some standard kind of tasks like batch requests and large file uploads and downloads and things like that cool so with the standard error codes one that comes up a lot is around falling and handling the write that you call that API is there anything the SDK does around kind of 49 yeah so what we have done is under the the SDK we've built kind of a middle or a pipeline where we can do all those kind of clever things like redirect handling and retry throttling so if you get a 429 and it has a retry after header we'll wait the appropriate amount of time same those if you get a 503 response there's a lot of different standard behavior that comes with HTTP that we're able to plug in these middleware components so this help you work a bunch of stuff you get four three by going down that path absolutely and and if I've already built an application that's using the Microsoft graph in that web stack using JavaScript are there benefits to starting to try and layer this SDK into your existing application well there's a variety approach well one thing that you can really get a lot of benefits immediately is just using our typescript types we take all the shapes of all the models request some response models across all the graph and we generate a typescript library so you can just plug that in and then all of a sudden you've got strong types for anytime so if you're ready getting a request back for your normal stack you can at least get yester only typing going yeah that's really neat what's the best way to get started with this for a developer well let me let me show you give you a demo I just opened here the page on github for our JavaScript libraries m/s graph - yes DK - JavaScript and we kind of give you a little walkthrough here show you some of the benefits of intellisense and show the how to install it either were an NPM package or via a script tag now one of the ways that I liked working with these things is just let's go see a little sample all right get the minimum kind of viable thing working so we've got a couple of samples here one running under node and one running for the browser and the browser it shows you how to get it all set up now I have it loaded up here on my machine it opened up in vs code and I got a few files opening first of all you're going to provide it at the client ID because I've got to get the auth working so you'll fill in the client ID in the secret ICS file it's a very simple one-page HTML page and we pull in the MS ljs library here and also the our graph SDK library there's one main Jas file that gets loaded up on page load and you can see in here how we're setting up what's called the user agent application which is the MSL way of configuring the security parameters for the application in this case the client ID and then we have our earth provider which is kind of an adapter to MSL and working with the graph and we'll take care of taking that Tok and putting it in the right place and handling certain error codes that come back from emcell just MSL is the Microsoft authentication library that helps with the whole process of authenticating the user that's going to be yeah it's our standard approach for well for any application using Azure ad em Sol library works we just kind of specialized this adapter to help you with the graph scenario yep so this particular client gets set up here this Microsoft graph client and then we have a small request like we just kind of show you how to use it so you do client API slash me get and it will return back the user profile you can slice slash mede slash messages there's a bunch of different examples in here and if I were to just do an NPM start on here you'll see what this application looks like when it's running so little browser I click the one of these buttons here get my details when I make that request this as oh this is not authenticated oh I better get an authentication token so it pops up this login dialog which is handled by himself for us we click on here and it's gonna sign in and then it's going to oh well first it's going to authenticate the application right give consent to the application for all the things that it wants to access we click accept and then it's going to display the results out in the results app now if I click on get my mails we won't have to go through that same dance because there's a token cache there that has all that information I can go click on that and it returns back just a JSON blob of all of my emails that's really none that's as easy as it is to get started great so if you're interested in this and you want to get started today graph dot microsoft comm click get start at the top you'll see Java scripts is one of the options there and we give you a tutorial to get started links straight to the sdk pages Daryll just showed as well as a quick start there we can get up and going within a few minutes so thanks for your time they're already based on Jeremy

Original Description

Learn how the JS Microsoft Graph SDKs will help you as a developer, including how the SDK can help with getting an Auth token for the API, status codes and some SDK sample code. To learn more about the Microsoft Graph and JS SDKs, visit https://docs.microsoft.com/en-us/graph/sdks/sdks-overview For additional Microsoft Graph tools and resources, visit https://graph.microsoft.com.
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Microsoft 365 Developer · Microsoft 365 Developer · 23 of 60

1 Adaptive Cards community call-February 2019
Adaptive Cards community call-February 2019
Microsoft 365 Developer
2 PowerApps community call-February 2019
PowerApps community call-February 2019
Microsoft 365 Developer
3 Microsoft Graph community call-March 2019
Microsoft Graph community call-March 2019
Microsoft 365 Developer
4 Office Add ins community call-March 2019
Office Add ins community call-March 2019
Microsoft 365 Developer
5 PowerApps community call-March 2019
PowerApps community call-March 2019
Microsoft 365 Developer
6 Microsoft Teams community call-March 2019
Microsoft Teams community call-March 2019
Microsoft 365 Developer
7 Using React and Office UI Fabric React Components
Using React and Office UI Fabric React Components
Microsoft 365 Developer
8 Build Microsoft Teams customization using SharePoint Framework
Build Microsoft Teams customization using SharePoint Framework
Microsoft 365 Developer
9 Microsoft Graph community call-April 2019
Microsoft Graph community call-April 2019
Microsoft 365 Developer
10 Using Change Notifications and Track Changes with Microsoft Graph
Using Change Notifications and Track Changes with Microsoft Graph
Microsoft 365 Developer
11 Office Add Ins community call-April 2019
Office Add Ins community call-April 2019
Microsoft 365 Developer
12 Adaptive Cards community call-April 2019
Adaptive Cards community call-April 2019
Microsoft 365 Developer
13 Microsoft Teams community call-April 2019
Microsoft Teams community call-April 2019
Microsoft 365 Developer
14 Getting Started with Microsoft Graph and Application Registration
Getting Started with Microsoft Graph and Application Registration
Microsoft 365 Developer
15 Getting Started with Microsoft Graph and the Directory API
Getting Started with Microsoft Graph and the Directory API
Microsoft 365 Developer
16 Getting Started with Microsoft Graph and Microsoft Teams
Getting Started with Microsoft Graph and Microsoft Teams
Microsoft 365 Developer
17 Getting Started with Microsoft Graph Explorer
Getting Started with Microsoft Graph Explorer
Microsoft 365 Developer
18 Getting Started with Microsoft Graph
Getting Started with Microsoft Graph
Microsoft 365 Developer
19 Getting Started with Microsoft Graph and Mail API
Getting Started with Microsoft Graph and Mail API
Microsoft 365 Developer
20 Getting Started with Microsoft Graph and Office 365 Groups
Getting Started with Microsoft Graph and Office 365 Groups
Microsoft 365 Developer
21 Getting Started with Microsoft Graph and the Calendar API
Getting Started with Microsoft Graph and the Calendar API
Microsoft 365 Developer
22 Getting Started with the Microsoft Graph Toolkit
Getting Started with the Microsoft Graph Toolkit
Microsoft 365 Developer
Getting Started with Microsoft Graph and JavaScript SDKs
Getting Started with Microsoft Graph and JavaScript SDKs
Microsoft 365 Developer
24 Getting Started with Microsoft Graph and .NET SDKs
Getting Started with Microsoft Graph and .NET SDKs
Microsoft 365 Developer
25 Discover how businesses can be more productive with Microsoft 365 integrations
Discover how businesses can be more productive with Microsoft 365 integrations
Microsoft 365 Developer
26 Adaptive Cards community call-May 2019
Adaptive Cards community call-May 2019
Microsoft 365 Developer
27 Office Add-ins community call-May 2019
Office Add-ins community call-May 2019
Microsoft 365 Developer
28 Why We Built on Microsoft Teams
Why We Built on Microsoft Teams
Microsoft 365 Developer
29 Microsoft Teams community call-May 2019
Microsoft Teams community call-May 2019
Microsoft 365 Developer
30 Microsoft Graph community call-June 2019
Microsoft Graph community call-June 2019
Microsoft 365 Developer
31 Build Angular SPA's with Microsoft Graph - June 2019
Build Angular SPA's with Microsoft Graph - June 2019
Microsoft 365 Developer
32 Office Add -ins community call-June 2019
Office Add -ins community call-June 2019
Microsoft 365 Developer
33 Build Android native apps with the Microsoft Graph Android SDK - June 2019
Build Android native apps with the Microsoft Graph Android SDK - June 2019
Microsoft 365 Developer
34 Build MVC apps with Microsoft Graph - June 2019
Build MVC apps with Microsoft Graph - June 2019
Microsoft 365 Developer
35 Authenticate and connect with Microsoft Graph - June 2019
Authenticate and connect with Microsoft Graph - June 2019
Microsoft 365 Developer
36 Microsoft Graph data connect - June 2019
Microsoft Graph data connect - June 2019
Microsoft 365 Developer
37 Change notifications with Microsoft Graph - June 2019
Change notifications with Microsoft Graph - June 2019
Microsoft 365 Developer
38 Build iOS native apps with the Microsoft Graph REST API - June 2019
Build iOS native apps with the Microsoft Graph REST API - June 2019
Microsoft 365 Developer
39 Build Node.js Express apps with Microsoft Graph - June 2019
Build Node.js Express apps with Microsoft Graph - June 2019
Microsoft 365 Developer
40 Smart UI with Microsoft Graph - June 2019
Smart UI with Microsoft Graph - June 2019
Microsoft 365 Developer
41 Leveraging the Microsoft Graph API from the SharePoint Framework - June 2019
Leveraging the Microsoft Graph API from the SharePoint Framework - June 2019
Microsoft 365 Developer
42 Build UWP apps with Microsoft Graph - June 2019
Build UWP apps with Microsoft Graph - June 2019
Microsoft 365 Developer
43 Build React SPA's with Microsoft Graph - June 2019
Build React SPA's with Microsoft Graph - June 2019
Microsoft 365 Developer
44 Getting Started with Microsoft Graph and Batching
Getting Started with Microsoft Graph and Batching
Microsoft 365 Developer
45 Getting Started with Microsoft Graph and Change Notifications
Getting Started with Microsoft Graph and Change Notifications
Microsoft 365 Developer
46 Getting Started with Microsoft Graph and Consent Permissions
Getting Started with Microsoft Graph and Consent Permissions
Microsoft 365 Developer
47 Getting Started with Microsoft Graph and Education
Getting Started with Microsoft Graph and Education
Microsoft 365 Developer
48 Getting Started with Microsoft Graph and Financials
Getting Started with Microsoft Graph and Financials
Microsoft 365 Developer
49 Getting Started with Microsoft Graph and Excel
Getting Started with Microsoft Graph and Excel
Microsoft 365 Developer
50 Getting Started with Microsoft Graph and Data Connect
Getting Started with Microsoft Graph and Data Connect
Microsoft 365 Developer
51 Getting Started with Microsoft Graph and Intune
Getting Started with Microsoft Graph and Intune
Microsoft 365 Developer
52 Getting Started with Microsoft Graph and Notifications
Getting Started with Microsoft Graph and Notifications
Microsoft 365 Developer
53 Getting Started with Microsoft Graph and OneNote
Getting Started with Microsoft Graph and OneNote
Microsoft 365 Developer
54 Getting Started with Microsoft Graph and OneDrive
Getting Started with Microsoft Graph and OneDrive
Microsoft 365 Developer
55 Getting Started with Microsoft Graph and Open Extensions
Getting Started with Microsoft Graph and Open Extensions
Microsoft 365 Developer
56 Getting Started with Microsoft Graph and Paging
Getting Started with Microsoft Graph and Paging
Microsoft 365 Developer
57 Getting Started with Microsoft Graph and Schema Extensions
Getting Started with Microsoft Graph and Schema Extensions
Microsoft 365 Developer
58 Getting Started with Microsoft Graph and Security API
Getting Started with Microsoft Graph and Security API
Microsoft 365 Developer
59 Getting Started with Microsoft Graph and Query Parameters
Getting Started with Microsoft Graph and Query Parameters
Microsoft 365 Developer
60 Getting Started with Microsoft Graph and Reporting API
Getting Started with Microsoft Graph and Reporting API
Microsoft 365 Developer

Get started with Microsoft Graph and JavaScript SDKs by handling authentication tokens, status codes, and SDK sample code. Learn how to integrate the SDK into an existing application and use TypeScript types for strong typing.

Key Takeaways
  1. Install the JavaScript SDK via NPM package or script tag
  2. Import the SDK and Microsoft Authentication Library
  3. Set up the client ID and secret in the auth provider
  4. Use the Microsoft Graph client to make requests
  5. Handle authentication tokens and status codes
💡 The Microsoft Graph JavaScript SDK provides a simple way to handle authentication tokens and status codes, making it easier to integrate the Microsoft Graph into your application.

Related AI Lessons

Up next
5 Levels of AI Agents - From Simple LLM Calls to Multi-Agent Systems
Dave Ebbelaar (LLM Eng)
Watch →