This function takes as an argument the Microsoft 365 account that has been used to sign in to the app and uses it to create a Microsoft Graph client that you'll use to call Microsoft Graph APIs and get data from Microsoft 365.Learn more about ProjectManager and how it can improve your businessĭiscover app combinations that improve your productivity Replace the TODO #2 comment with the following code: (() => ) Sign Users In with their Microsoft 365 Account Using these libraries will help you build your app faster, and you won't have to worry about the details of how to sign users in, get an access token, or properly handle API errors. the previously created env.js file with the ID of your app.MSAL Browser Auth Provider which integrates MSAL.js with the Microsoft Graph JS SDK.Microsoft Graph JavaScript SDK which simplifies calling Microsoft Graph – the API to access data and insights on Microsoft 365.MSAL.js which helps you handle signing users in with their Microsoft 365 account.To build this app you'll use a few libraries: Replace the TODO #1 comment with the following code: It also contains a div where you'll show the login/logout button and a pre element where you'll show the user's profile information. This code is a simple HTML page with two placeholders: one for the libraries that you'll use to build your app, and another for the app's code. Create a new file named index.html and paste the following code: Open your app folder in your code editor. In the terminal, run: echo "const appId = '$appId' " > env.js Create your App Next, write the ID of the newly created app to a file that you'll reference in your app. For single-page apps, you also need to specify the application's URL, which is used to ensure that users are signing in to the right app. With these two commands, you've used the CLI for Microsoft 365 to sign in to Microsoft 365 and register your new app on the Microsoft Cloud.Įvery app that integrates with Microsoft 365 must be registered and provide information such as the application's name and type (platform). Next, back in the terminal, run the following command: appId=$(npx -p - m365 aad app add -name "Hello world" -multitenant -redirectUris " -platform spa -query "appId" -o text) In your web browser, sign in with your newly created Microsoft 365 developer account: Sign into your Microsoft 365 developer account In the terminal, run the following command: npx -p - m365 login -authType browser Open a terminal and change the working directory to that folder. Ready? Let's go! Register your Application on the Microsoft CloudĬreate a folder for your application, where you'll store all app files. You can get one for free from Microsoft 365 developer program, and it'll give you access to all Microsoft 365 APIs you need to build your apps, along with some demo data to get started
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |