在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:microsoftgraph/msgraph-sdk-javascript开源软件地址:https://github.com/microsoftgraph/msgraph-sdk-javascript开源编程语言:TypeScript 95.6%开源软件介绍:Microsoft Graph JavaScript Client LibraryThe Microsoft Graph JavaScript client library is a lightweight wrapper around the Microsoft Graph API that can be used server-side and in the browser.
Looking for IntelliSense on models (Users, Groups, etc.)? Check out the Microsoft Graph Types v1.0 and beta!! Node version requirementNode.js 12 LTS or higher. The active Long Term Service (LTS) version of Node.js is used for on-going testing of existing and upcoming product features. InstallationVia npmnpm install @microsoft/microsoft-graph-client import Also, you will need to import any fetch polyfill which suits your requirements. Following are some fetch polyfills - import "isomorphic-fetch"; // or import the fetch polyfill you installed
import { Client } from "@microsoft/microsoft-graph-client"; Via Script TagInclude graph-js-sdk.js in your HTML page. <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@microsoft/microsoft-graph-client/lib/graph-js-sdk.js"></script> In case your browser doesn't have support for Fetch [support] or Promise [support], you need to use polyfills like github/fetch for fetch and es6-promise for promise. <!-- polyfilling promise -->
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/es6-promise/dist/es6-promise.auto.min.js"></script>
<!-- polyfilling fetch -->
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/whatwg-fetch/dist/fetch.umd.min.js"></script>
<!-- depending on your browser you might wanna include babel polyfill -->
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@babel/[email protected]/dist/polyfill.min.js"></script> Getting started1. Register your applicationTo call Microsoft Graph, your app must acquire an access token from the Microsoft identity platform. Learn more about this -
2. Create a Client InstanceThe Microsoft Graph client is designed to make it simple to make calls to Microsoft Graph. You can use a single client instance for the lifetime of the application. For information on how to create a client instance, see Creating Client Instance 3. Make requests to the graphOnce you have authentication setup and an instance of Client, you can begin to make calls to the service. All requests should start with Example of getting user details: try {
let userDetails = await client.api("/me").get();
console.log(userDetails);
} catch (error) {
throw error;
} Example of sending an email to the recipients: // Construct email object
const mail = {
subject: "Microsoft Graph JavaScript Sample",
toRecipients: [
{
emailAddress: {
address: "[email protected]",
},
},
],
body: {
content: "<h1>MicrosoftGraph JavaScript Sample</h1>Check out https://github.com/microsoftgraph/msgraph-sdk-javascript",
contentType: "html",
},
};
try {
let response = await client.api("/me/sendMail").post({ message: mail });
console.log(response);
} catch (error) {
throw error;
} For more information, refer: Calling Pattern, Actions, Query Params, API Methods and more. Samples and tutorialsStep-by-step training exercises that guide you through creating a basic application that accesses data via the Microsoft Graph:
The Microsoft Graph JavaScript SDK provides a
The Microsoft Graph JavaScript SDK provides a
Questions and commentsWe'd love to get your feedback about the Microsoft Graph JavaScript client library. You can send your questions and suggestions to us in the Issues section of this repository. ContributingPlease see the contributing guidelines. Additional resources
Third Party NoticesSee Third Party Notices for information on the packages that are included in the package.json Security ReportingIf you find a security issue with our libraries or services please report it to [email protected] with as much detail as possible. Your submission may be eligible for a bounty through the Microsoft Bounty program. Please do not post security issues to GitHub Issues or any other public site. We will contact you shortly upon receiving the information. We encourage you to get notifications of when security incidents occur by visiting this page and subscribing to Security Advisory Alerts. LicenseCopyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License (the "License"); We Value and Adhere to the Microsoft Open Source Code of ConductThis project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论