安装 Microsoft Graph SdkInstall the Microsoft Graph SDKs

Microsoft Graph Sdk 可通过 GitHub 和热门平台包管理器包含在您的项目中。The Microsoft Graph SDKs are available to be included in your projects via GitHub and popular platform package managers. 本主题介绍如何将 Microsoft Graph SDK 安装到您的项目中。This topic describes how you can install the Microsoft Graph SDK into your project.

安装 Microsoft Graph .NET SDKInstall the Microsoft Graph .NET SDK

Microsoft Graph .NET SDK 包含在以下 NuGet 包中:The Microsoft Graph .NET SDK is included in the following NuGet packages:

  • Microsoft. Graph -包含用于通过流畅的 API 访问v1.0终结点的模型和请求生成器。Microsoft.Graph - Contains the models and request builders for accessing the v1.0 endpoint with the fluent API. Microsoft. Graph 具有对 Microsoft. Core 的依赖性。Microsoft.Graph has a dependency on Microsoft.Graph.Core.
  • Microsoft. Beta -包含用于通过流畅的 API 访问beta终结点的模型和请求生成器。Microsoft.Graph.Beta - Contains the models and request builders for accessing the beta endpoint with the fluent API. Microsoft. Graph 与 Microsoft. 酷睿单的依赖项。Microsoft.Graph.Beta has a dependency on Microsoft.Graph.Core.
  • Microsoft. core -用于调用 Microsoft Graph 的核心库。Microsoft.Graph.Core - The core library for making calls to Microsoft Graph.
  • MSAL-提供用于 Microsoft Graph SDK的 Microsoft 身份验证库()的基于身份验证方案的包装。Microsoft.Graph.Auth - Provides an authentication scenario-based wrapper of the Microsoft Authentication Library (MSAL) for use with the Microsoft Graph SDK. Microsoft. Auth 依赖于 Microsoft. Core。Microsoft.Graph.Auth has a dependency on Microsoft.Graph.Core.

您可以使用Visual Studio 或程序包管理器控制台中的程序包管理器 UI将 Microsoft. 包安装到您的项目中。You can use either the Package Manager UI in Visual Studio or the Package Manager Console to install the Microsoft.Graph packages into your project. 下面的程序包管理器控制台命令将安装 Microsoft. graph 和 Microsoft. Core 和 the the Auth 库。The following Package Manager Console commands will install the Microsoft.Graph, Microsoft.Graph.Core, and Microsoft.Graph.Auth libraries. 作为 Microsoft Graph 的依赖项安装了 "(Graph)"。Microsoft.Graph.Core is installed as a dependency of Microsoft.Graph.

Install-Package Microsoft.Graph
Install-Package Microsoft.Graph.Auth -IncludePrerelease

安装 Microsoft Graph Java SDKInstall the Microsoft Graph Java SDK

Microsoft Graph Java SDK 包含在以下包中:The Microsoft Graph Java SDK is included in the following packages:

  • microsoft-graph -包含用于通过流畅的 API 访问v1.0终结点的模型和请求生成器。microsoft-graph - Contains the models and request builders for accessing the v1.0 endpoint with the fluent API.
  • microsoft-core -用于调用 microsoft graph 的核心库。microsoft-graph-core - The core library for making calls to Microsoft Graph.
  • microsoft-graph-auth -提供基于身份验证的 microsoft 身份验证库(MSAL)的包装,以与 MICROSOFT graph SDK 配合使用。microsoft-graph-auth - Provides an authentication scenario-based wrapper of Microsoft Authentication Library (MSAL) for use with the Microsoft Graph SDK.

通过 Gradle 安装 Microsoft Graph Java SDKInstall the Microsoft Graph Java SDK via Gradle

将 microsoft graph 的存储库和编译依赖项添加到项目的生成中。 gradle:Add the repository and a compile dependency for microsoft-graph to your project's build.gradle:

repository {
    jcenter()
}

dependency {
    // Include the sdk as a dependency
    compile('com.microsoft.graph:microsoft-graph:1.2.+')
}

通过 Maven 安装 Microsoft Graph Java SDKInstall the Microsoft Graph Java SDK via Maven

在 pom 中的 dependency 元素中添加依赖关系:Add the dependency in the dependencies element in pom.xml:

<dependency>
    <groupId>com.microsoft.graph</groupId>
    <artifactId>microsoft-graph</artifactId>
    <version>1.2.0</version>
</dependency>

安装 Microsoft Graph Javascript SDKInstall the Microsoft Graph Javascript SDK

Microsoft Graph Javascript SDK 包含在以下包中:The Microsoft Graph Javascript SDK is included in the following packages:

  • @microsoft/microsoft-graph-client (npm)-用于调用 microsoft graph 的核心库。@microsoft/microsoft-graph-client (npm)- The core library for making calls to Microsoft Graph.
  • @microsoft/microsoft-graph-types (npm)-microsoft graph 实体的 Typescript 类型。@microsoft/microsoft-graph-types (npm) - The Typescript types for the Microsoft Graph entities.

您可以使用npm安装 Microsoft GRAPH Javascript SDK:You can use npm to install the Microsoft Graph Javascript SDK:

npm install @microsoft/microsoft-graph-client
npm install @microsoft/microsoft-graph-types --save-dev

安装 Microsoft Graph 目标-C SDKInstall the Microsoft Graph Objective-C SDK

Microsoft Graph 客观-C SDK 支持 iOS 和 macOS 平台,并且可以使用 CocoaPods 或 Carthage 将其安装到项目中。The Microsoft Graph Objective-C SDK supports both iOS and macOS platforms and can be installed into your project using either CocoaPods or Carthage.

使用 Cocoapods 安装 Microsoft Graph 目标-C SDKInstall the Microsoft Graph Objective-C SDK using Cocoapods

在您的 podfile 中添加以下行,以在 xcode 项目中包含目标-C Microsoft Graph SDK 和 Microsoft Graph 目标-C Auth SDK:Add the following line in your podfile to include the Objective-C Microsoft Graph SDK and Microsoft Graph Objective-C Auth SDK in your xcode project:

pod 'MSGraphClientSDK'
pod 'MSGraphMSALAuthProvider'

使用 Carthage 安装 Microsoft Graph 目标-C SDKInstall the Microsoft Graph Objective-C SDK using Carthage

执行以下步骤,以使用Carthage程序包管理器安装 Microsoft graph 目标-c SDK 和 Microsoft graph 目标-c Auth sdk。Perform the following steps to install the Microsoft Graph Objective-C SDK and Microsoft Graph Objective-C Auth SDK using the Carthage package manager.

  1. 创建一个Cartfile ,用于指定目标-C SDK GitHub 存储库和目标的发布标记Create a Cartfile that specifies the Objective-C SDK GitHub repository and release tag to target.
github "microsoftgraph/msgraph-sdk-objc" "tags/<latest_release_tag>"
github "microsoftgraph/msgraph-sdk-objc-auth" "tags/<latest_release_tag>"
  1. 运行carthage updateRun carthage update. 这会将依赖项提取到 Carthage/签出文件夹中,然后生成 MSGraphClientSDK 库。This will fetch dependencies into a Carthage/Checkouts folder and then builds the MSGraphClientSDK library.

  2. 使用 Xcode,在应用程序目标的 "常规设置" 选项卡中的 "链接的框架和库" 部分,从磁盘上的 Carthage/Build 文件夹中拖放MSGraphClientSDKMSGraphMSALAuthProvider 框架Using Xcode, in your application target's General settings tab, in the Linked Frameworks and Libraries section, drag and drop the MSGraphClientSDK.framework and MSGraphMSALAuthProvider.framework from the Carthage/Build folder on disk.

  3. 在应用程序目标的 "生成阶段设置" 选项卡**+** 上,单击 "" 图标,然后选择 "新建运行脚本阶段"。On your application target's Build Phases settings tab, click the + icon and choose New Run Script Phase. 创建一个运行脚本,在其中指定命令行管理程序(例如:/bin/sh),并将以下内容添加到脚本:Create a run script in which you specify your shell (ex: /bin/sh), and add the following contents to the script:

/usr/local/bin/carthage copy-frameworks
  1. 将路径添加到您要在 "输入文件" 下使用的框架。Add the paths to the frameworks you want to use under Input Files.
$(SRCROOT)/Carthage/Build/iOS/MSGraphClientSDK.framework
$(SRCROOT)/Carthage/Build/iOS/MSGraphMSALAuthProvider.framework

安装 Microsoft Graph PHP SDKInstall the Microsoft Graph PHP SDK

Microsoft GRAPH PHP SDK可从packagist.org中获取,并可通过以下方式安装:The Microsoft Graph PHP SDK is available from packagist.org and can be installed in the following ways:

使用书写器手动安装 Microsoft Graph PHP SDKInstall the Microsoft Graph PHP SDK manually using composer

composer require microsoft/microsoft-graph

使用作曲. json 安装 Microsoft Graph PHP SDKInstall the Microsoft Graph PHP SDK using composer.json

{
    "require": {
        "microsoft/microsoft-graph": "^1.8"
    }
}

安装 Microsoft Graph Ruby SDKInstall the Microsoft Graph Ruby SDK

Microsoft Graph RUBY SDK可从rubygems.org中获取,可以使用以下命令进行安装:The Microsoft Graph Ruby SDK is available from rubygems.org and can be installed using the following command:

gem install microsoft_graph