@microsoft/msgraph-sdk 1.0.0-preview.55 → 1.0.0-preview.57

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,11 +1,192 @@
1
- # `@microsoft/msgraph-sdk`
1
+ # Microsoft Graph SDK for Typescript
2
2
 
3
- > TODO: description
3
+ Get started with the Microsoft Graph SDK for Typescript by integrating the [Microsoft Graph API](https://learn.microsoft.com/graph/overview) into your Typescript application!
4
4
 
5
- ## Usage
5
+ > [!NOTE]
6
+ > The Microsoft Graph Typescript SDK is currently in Pre-Release. This SDK allows you to build applications using the [v1.0](https://learn.microsoft.com/graph/use-the-api#version) of Microsoft Graph. If you want to try the latest Microsoft Graph APIs, use our [beta SDK](https://github.com/microsoftgraph/msgraph-beta-sdk-typescript) instead.
6
7
 
8
+
9
+ ## 1. Installation
10
+
11
+ ```shell
12
+ # this will install the main package
13
+ npm install @microsoft/msgraph-sdk
14
+ # this will install the authentication provider for Azure Identity / Microsoft Entra
15
+ npm install @microsoft/kiota-authentication-azure @azure/identity
16
+ # this will install the fluent API package for the users API paths
17
+ npm install @microsoft/msgraph-sdk-users
18
+ ```
19
+
20
+ ## 2. Getting started
21
+
22
+ > 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.
23
+
24
+ ### 2.1 Register your application
25
+
26
+ Register your application by following the steps at [Register your app with the Microsoft Identity Platform](https://learn.microsoft.com/graph/auth-register-app-v2).
27
+
28
+ ### 2.2 Create an AuthenticationProvider object
29
+
30
+ 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.
31
+
32
+ <!-- TODO restore that and remove the snippets below once the SDK hits GA and the public documentation has been updated -->
33
+ <!-- For an example of how to get an authentication provider, see [choose a Microsoft Graph authentication provider](https://learn.microsoft.com/graph/sdks/choose-authentication-providers?tabs=typescript). -->
34
+
35
+ #### 2.2.1 Authorization Code Provider
36
+
37
+ ```TypeScript
38
+ // @azure/identity
39
+ const credential = new AuthorizationCodeCredential(
40
+ 'YOUR_TENANT_ID',
41
+ 'YOUR_CLIENT_ID',
42
+ 'YOUR_CLIENT_SECRET',
43
+ 'AUTHORIZATION_CODE',
44
+ 'REDIRECT_URL',
45
+ );
46
+
47
+ // @microsoft/kiota-authentication-azure
48
+ const authProvider = new AzureIdentityAuthenticationProvider(credential, ["User.Read"]);
49
+ ```
50
+
51
+ #### 2.2.2 Client Credentials Provider
52
+
53
+ ##### With a certificate
54
+
55
+ ```TypeScript
56
+ // @azure/identity
57
+ const credential = new ClientCertificateCredential(
58
+ 'YOUR_TENANT_ID',
59
+ 'YOUR_CLIENT_ID',
60
+ 'YOUR_CERTIFICATE_PATH',
61
+ );
62
+
63
+ // @microsoft/kiota-authentication-azure
64
+ const authProvider = new AzureIdentityAuthenticationProvider(credential, ["https://graph.microsoft.com/.default"]);
7
65
  ```
8
- const msgraphSdkJavascript = require('@microsoft/msgraph-sdk');
9
66
 
10
- // TODO: DEMONSTRATE API
67
+ ##### With a secret
68
+
69
+ ```TypeScript
70
+ // @azure/identity
71
+ const credential = new ClientSecretCredential(
72
+ 'YOUR_TENANT_ID',
73
+ 'YOUR_CLIENT_ID',
74
+ 'YOUR_CLIENT_SECRET',
75
+ );
76
+
77
+ // @microsoft/kiota-authentication-azure
78
+ const authProvider = new AzureIdentityAuthenticationProvider(credential, ["https://graph.microsoft.com/.default"]);
11
79
  ```
80
+
81
+ #### 2.2.3 On-behalf-of provider
82
+
83
+ ```TypeScript
84
+ // @azure/identity
85
+ const credential = new OnBehalfOfCredential({
86
+ tenantId: 'YOUR_TENANT_ID',
87
+ clientId: 'YOUR_CLIENT_ID',
88
+ clientSecret: 'YOUR_CLIENT_SECRET',
89
+ userAssertionToken: 'JWT_TOKEN_TO_EXCHANGE',
90
+ });
91
+
92
+ // @microsoft/kiota-authentication-azure
93
+ const authProvider = new AzureIdentityAuthenticationProvider(credential, ["https://graph.microsoft.com/.default"]);
94
+ ```
95
+
96
+ #### 2.2.4 Device code provider
97
+
98
+ ```TypeScript
99
+ // @azure/identity
100
+ const credential = new DeviceCodeCredential({
101
+ tenantId: 'YOUR_TENANT_ID',
102
+ clientId: 'YOUR_CLIENT_ID',
103
+ userPromptCallback: (info) => {
104
+ console.log(info.message);
105
+ },
106
+ });
107
+
108
+ // @microsoft/kiota-authentication-azure
109
+ const authProvider = new AzureIdentityAuthenticationProvider(credential, ["User.Read"]);
110
+ ```
111
+
112
+ #### 2.2.5 Interactive provider
113
+
114
+ ```TypeScript
115
+ // @azure/identity
116
+ const credential = new InteractiveBrowserCredential({
117
+ tenantId: 'YOUR_TENANT_ID',
118
+ clientId: 'YOUR_CLIENT_ID',
119
+ redirectUri: 'http://localhost',
120
+ });
121
+
122
+ // @microsoft/kiota-authentication-azure
123
+ const authProvider = new AzureIdentityAuthenticationProvider(credential, ["User.Read"]);
124
+ ```
125
+
126
+ #### 2.2.6 Username/password provider
127
+
128
+ ```TypeScript
129
+ // @azure/identity
130
+ const credential = new UsernamePasswordCredential(
131
+ 'YOUR_TENANT_ID',
132
+ 'YOUR_CLIENT_ID',
133
+ 'YOUR_USER_NAME',
134
+ 'YOUR_PASSWORD',
135
+ );
136
+
137
+ // @microsoft/kiota-authentication-azure
138
+ const authProvider = new AzureIdentityAuthenticationProvider(credential, ["User.Read"]);
139
+ ```
140
+
141
+ ### 2.3 Get a Graph Service Client Adapter object
142
+
143
+ You must get a **GraphServiceClient** object to make requests against the service.
144
+
145
+ ```typescript
146
+ const requestAdapter = new GraphRequestAdapter(authProvider);
147
+ const graphServiceClient = createGraphServiceClient(requestAdapter);
148
+ ```
149
+
150
+ ## 3. Make requests against the service
151
+
152
+ 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](https://learn.microsoft.com/graph/api/overview?view=graph-rest-1.0).
153
+
154
+ ### 3.1 Get user's detailed information
155
+
156
+ To retrieve the user's detailed information:
157
+
158
+ ```typescript
159
+ import { createGraphServiceClient, GraphRequestAdapter } from "@microsoft/msgraph-sdk";
160
+ import "@microsoft/msgraph-sdk-users";
161
+
162
+ const requestAdapter = new GraphRequestAdapter(authProvider);
163
+ const graphServiceClient = createGraphServiceClient(requestAdapter);
164
+
165
+ const jane = await graphServiceClient.users.byUserId("jane@contoso.com").get();
166
+ ```
167
+
168
+ ## 4. Documentation
169
+
170
+ For more detailed documentation, see:
171
+
172
+ * [Overview](https://learn.microsoft.com/graph/overview)
173
+ * [Collections](https://learn.microsoft.com/graph/sdks/paging)
174
+ * [Making requests](https://learn.microsoft.com/graph/sdks/create-requests)
175
+ * [Known issues](https://github.com/MicrosoftGraph/msgraph-sdk-typescript/issues)
176
+ * [Contributions](https://github.com/microsoftgraph/msgraph-sdk-typescript/blob/main/CONTRIBUTING.md)
177
+
178
+ ## 5. Issues
179
+
180
+ For known issues, see [issues](https://github.com/MicrosoftGraph/msgraph-sdk-typescript/issues).
181
+
182
+ ## 6. Contributions
183
+
184
+ The Microsoft Graph SDK is open for contribution. To contribute to this project, see [Contributing](https://github.com/microsoftgraph/msgraph-sdk-typescript/blob/main/CONTRIBUTING.md).
185
+
186
+ ## 7. License
187
+
188
+ Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the [MIT license](LICENSE).
189
+
190
+ ## 8. Third-party notices
191
+
192
+ [Third-party notices](THIRD%20PARTY%20NOTICES)