@microsoft/msgraph-sdk-shares
TypeScript icon, indicating that this package has built-in type declarations

1.0.0-preview.57 • Public • Published

@microsoft/msgraph-sdk-shares

Get started with the Microsoft Graph SDK for TypeScript by integrating the Microsoft Graph API into your TypeScript application!

This package provides a fluent API for interacting with Microsoft Graph administrative functions.

[!NOTE] This package requires the @microsoft/msgraph-sdk package. It allows you to build applications using the v1.0 of Microsoft Graph. If you want to try the latest Microsoft Graph APIs, use our beta SDK instead.

1. Installation

To install the package, use npm:

# this will install the main package
npm install @microsoft/msgraph-sdk
# this will install the authentication provider for Azure Identity / Microsoft Entra
npm install @microsoft/kiota-authentication-azure @azure/identity
# this will install the fluent API package for the administrative API paths
npm install @microsoft/msgraph-sdk-shares

2. Getting started

Note: we are working to add the getting started information for Typescript to our public documentation, in the meantime the following sample should help you getting started.

2.1 Register your application

Register your application by following the steps at Register your app with the Microsoft Identity Platform.

2.2 Create an AuthenticationProvider object

An instance of the GraphServiceClient class handles building client. To create a new instance of this class, you need to provide an instance of AuthenticationProvider, which can authenticate requests to Microsoft Graph.

2.2.1 Authorization Code Provider

// @azure/identity
const credential = new AuthorizationCodeCredential(
  'YOUR_TENANT_ID',
  'YOUR_CLIENT_ID',
  'YOUR_CLIENT_SECRET',
  'AUTHORIZATION_CODE',
  'REDIRECT_URL',
);

// @microsoft/kiota-authentication-azure
const authProvider = new AzureIdentityAuthenticationProvider(credential, ["User.Read"]);

2.2.2 Client Credentials Provider

With a certificate
// @azure/identity
const credential = new ClientCertificateCredential(
  'YOUR_TENANT_ID',
  'YOUR_CLIENT_ID',
  'YOUR_CERTIFICATE_PATH',
);

// @microsoft/kiota-authentication-azure
const authProvider = new AzureIdentityAuthenticationProvider(credential, ["https://graph.microsoft.com/.default"]);
With a secret
// @azure/identity
const credential = new ClientSecretCredential(
  'YOUR_TENANT_ID',
  'YOUR_CLIENT_ID',
  'YOUR_CLIENT_SECRET',
);

// @microsoft/kiota-authentication-azure
const authProvider = new AzureIdentityAuthenticationProvider(credential, ["https://graph.microsoft.com/.default"]);

2.2.3 On-behalf-of provider

// @azure/identity
const credential = new OnBehalfOfCredential({
  tenantId: 'YOUR_TENANT_ID',
  clientId: 'YOUR_CLIENT_ID',
  clientSecret: 'YOUR_CLIENT_SECRET',
  userAssertionToken: 'JWT_TOKEN_TO_EXCHANGE',
});

// @microsoft/kiota-authentication-azure
const authProvider = new AzureIdentityAuthenticationProvider(credential, ["https://graph.microsoft.com/.default"]);

2.2.4 Device code provider

// @azure/identity
const credential = new DeviceCodeCredential({
  tenantId: 'YOUR_TENANT_ID',
  clientId: 'YOUR_CLIENT_ID',
  userPromptCallback: (info) => {
    console.log(info.message);
  },
});

// @microsoft/kiota-authentication-azure
const authProvider = new AzureIdentityAuthenticationProvider(credential, ["User.Read"]);

2.2.5 Interactive provider

// @azure/identity
const credential = new InteractiveBrowserCredential({
  tenantId: 'YOUR_TENANT_ID',
  clientId: 'YOUR_CLIENT_ID',
  redirectUri: 'http://localhost',
});

// @microsoft/kiota-authentication-azure
const authProvider = new AzureIdentityAuthenticationProvider(credential, ["User.Read"]);

2.2.6 Username/password provider

// @azure/identity
const credential = new UsernamePasswordCredential(
  'YOUR_TENANT_ID',
  'YOUR_CLIENT_ID',
  'YOUR_USER_NAME',
  'YOUR_PASSWORD',
);

// @microsoft/kiota-authentication-azure
const authProvider = new AzureIdentityAuthenticationProvider(credential, ["User.Read"]);

2.3 Get a Graph Service Client Adapter object

You must get a GraphServiceClient object to make requests against the service.

const requestAdapter = new GraphRequestAdapter(authProvider);
const graphServiceClient = createGraphServiceClient(requestAdapter);

3. Make requests against the service

After you have a GraphServiceClient that is authenticated, you can begin making calls against the service. The requests against the service look like our REST API.

3.1 Get user's detailed information

To retrieve the user's detailed information:

import { createGraphServiceClient, GraphRequestAdapter } from "@microsoft/msgraph-sdk";
import "@microsoft/msgraph-sdk-shares"

const requestAdapter = new GraphRequestAdapter(authProvider);
const graphServiceClient = createGraphServiceClient(requestAdapter);

const shares = graphServiceClient.shares.get();

4. Documentation

For more detailed documentation, see:

5. Issues

For known issues, see issues.

6. Contributions

The Microsoft Graph SDK is open for contribution. To contribute to this project, see Contributing.

7. License

Licensed under the MIT license.

8. Third-party notices

Third-party notices

Package Sidebar

Install

npm i @microsoft/msgraph-sdk-shares

Weekly Downloads

101

Version

1.0.0-preview.57

License

MIT

Unpacked Size

834 kB

Total Files

405

Last publish

Collaborators

  • microsoftgraph
  • microsoft1es