Skip to content

Commit a8fa86e

Browse files
committed
use Microsoft Graph SDK in code snippets
1 parent 9d16099 commit a8fa86e

File tree

7 files changed

+30
-33
lines changed

7 files changed

+30
-33
lines changed

articles/communication-services/concepts/includes/identifiers/identifiers-android.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,18 @@ var sameUser = new CommunicationUserIdentifier(newUserId);
3535

3636
### Microsoft Teams User identifier
3737

38-
The `MicrosoftTeamsUserIdentifier` represents a Teams user with its Azure AD user object ID. You can retrieve the Azure AD user object ID via the [Microsoft Graph REST API /users](/graph/api/user-get) endpoint from the `id` property in the response. Alternatively, you can find the ID as the `oid` claim in an [Azure AD ID token](/azure/active-directory/develop/id-tokens#payload-claims) or [Azure AD access token](/azure/active-directory/develop/access-tokens#payload-claims) after your user has signed in and acquired a token.
38+
The `MicrosoftTeamsUserIdentifier` represents a Teams user with its Azure AD user object ID. You can retrieve the Azure AD user object ID via the [Microsoft Graph REST API /users](/graph/api/user-get) endpoint from the `id` property in the response . For more information on how to work with Microsoft Graph, try the [Graph Explorer](https://developer.microsoft.com/en-us/graph/graph-explorer?request=users%2F%7Buser-mail%7D&method=GET&version=v1.0&GraphUrl=https://graph.microsoft.com) and look into the [Graph SDK](/graph/sdks/sdks-overview). Alternatively, you can find the ID as the `oid` claim in an [Azure AD ID token](/azure/active-directory/develop/id-tokens#payload-claims) or [Azure AD access token](/azure/active-directory/develop/access-tokens#payload-claims) after your user has signed in and acquired a token.
3939

4040
#### Basic usage
4141

4242
```java
43-
// get the Teams user's ID if only the email is known, assuming a helper method
44-
String userId = getUserIdFromGraph("[email protected]");
43+
// get the Teams user's ID from Graph APIs if only the email is known
44+
var user = await graphClient.users("[email protected]")
45+
.buildRequest()
46+
.get();
4547

4648
// create an identifier
47-
var teamsUser = new MicrosoftTeamsUserIdentifier(userId);
49+
var teamsUser = new MicrosoftTeamsUserIdentifier(user.id);
4850

4951
// if you're not operating in the public cloud, you must also set the right Cloud type.
5052
var gcchTeamsUser = new MicrosoftTeamsUserIdentifier(userId).setCloudEnvironment(CommunicationCloudEnvironment.GCCH);

articles/communication-services/concepts/includes/identifiers/identifiers-ios.md

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ let user = CommunicationUserIdentifier(newUserId)
3333

3434
### Microsoft Teams User identifier
3535

36-
The `MicrosoftTeamsUserIdentifier` represents a Teams user with its Azure AD user object ID. You can retrieve the Azure AD user object ID via the [Microsoft Graph REST API /users](/graph/api/user-get) endpoint from the `id` property in the response. Alternatively, you can find the ID as the `oid` claim in an [Azure AD ID token](/azure/active-directory/develop/id-tokens#payload-claims) or [Azure AD access token](/azure/active-directory/develop/access-tokens#payload-claims) after your user has signed in and acquired a token.
36+
The `MicrosoftTeamsUserIdentifier` represents a Teams user with its Azure AD user object ID. You can retrieve the Azure AD user object ID via the [Microsoft Graph REST API /users](/graph/api/user-get) endpoint from the `id` property in the response . For more information on how to work with Microsoft Graph, try the [Graph Explorer](https://developer.microsoft.com/en-us/graph/graph-explorer?request=users%2F%7Buser-mail%7D&method=GET&version=v1.0&GraphUrl=https://graph.microsoft.com) and look into the [Graph SDK](/graph/sdks/sdks-overview). Alternatively, you can find the ID as the `oid` claim in an [Azure AD ID token](/azure/active-directory/develop/id-tokens#payload-claims) or [Azure AD access token](/azure/active-directory/develop/access-tokens#payload-claims) after your user has signed in and acquired a token.
3737

3838
#### Basic usage
3939

4040
```swift
41-
// get the Teams user's ID if only the email is known, assuming a helper method
41+
// get the Teams user's ID if only the email is known, assuming a helper method for the Graph API
4242
let userId = await getUserIdFromGraph("[email protected]")
4343

4444
// create an identifier
@@ -121,13 +121,4 @@ let rawId = communicationIdentifier.rawId;
121121
let identifier = createCommunicationIdentifier(fromRawId: rawId);
122122
```
123123

124-
*ObjC*
125-
```swift
126-
// get an identifier's raw Id
127-
NSString *rawId = communicationIdentifier.rawId;
128-
129-
// create an identifier from a given raw Id
130-
id<CommunicationIdentifier> identifier = [CommunicationIdentifierFactory createCommunicationIdentifier:rawId];
131-
```
132-
133124
An invalid raw ID will just convert to an `UnknownIdentifier` in the SDK and any validation only happens service-side.

articles/communication-services/concepts/includes/identifiers/identifiers-java.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,18 @@ var sameUser = new CommunicationUserIdentifier(newUserId);
3535

3636
### Microsoft Teams User identifier
3737

38-
The `MicrosoftTeamsUserIdentifier` represents a Teams user with its Azure AD user object ID. You can retrieve the Azure AD user object ID via the [Microsoft Graph REST API /users](/graph/api/user-get) endpoint from the `id` property in the response. Alternatively, you can find the ID as the `oid` claim in an [Azure AD ID token](/azure/active-directory/develop/id-tokens#payload-claims) or [Azure AD access token](/azure/active-directory/develop/access-tokens#payload-claims) after your user has signed in and acquired a token.
38+
The `MicrosoftTeamsUserIdentifier` represents a Teams user with its Azure AD user object ID. You can retrieve the Azure AD user object ID via the [Microsoft Graph REST API /users](/graph/api/user-get) endpoint from the `id` property in the response . For more information on how to work with Microsoft Graph, try the [Graph Explorer](https://developer.microsoft.com/en-us/graph/graph-explorer?request=users%2F%7Buser-mail%7D&method=GET&version=v1.0&GraphUrl=https://graph.microsoft.com) and look into the [Graph SDK](/graph/sdks/sdks-overview). Alternatively, you can find the ID as the `oid` claim in an [Azure AD ID token](/azure/active-directory/develop/id-tokens#payload-claims) or [Azure AD access token](/azure/active-directory/develop/access-tokens#payload-claims) after your user has signed in and acquired a token.
3939

4040
#### Basic usage
4141

4242
```java
43-
// get the Teams user's ID if only the email is known, assuming a helper method
44-
String userId = getUserIdFromGraph("[email protected]");
43+
// get the Teams user's ID from Graph APIs if only the email is known
44+
var user = await graphClient.users("[email protected]")
45+
.buildRequest()
46+
.get();
4547

4648
// create an identifier
47-
var teamsUser = new MicrosoftTeamsUserIdentifier(userId);
49+
var teamsUser = new MicrosoftTeamsUserIdentifier(user.id);
4850

4951
// if you're not operating in the public cloud, you must also set the right Cloud type.
5052
var gcchTeamsUser = new MicrosoftTeamsUserIdentifier(userId).setCloudEnvironment(CommunicationCloudEnvironment.GCCH);

articles/communication-services/concepts/includes/identifiers/identifiers-js.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,16 @@ const sameUser = { communicationUserId: newUserId };
3535

3636
### Microsoft Teams User identifier
3737

38-
The `MicrosoftTeamsUserIdentifier` interface represents a Teams user. You need to know the Teams user's ID that you can retrieve via the [Microsoft Graph REST API /users](/graph/api/user-get) endpoint.
38+
The `MicrosoftTeamsUserIdentifier` interface represents a Teams user with its Azure AD user object ID. You can retrieve the Azure AD user object ID via the [Microsoft Graph REST API /users](/graph/api/user-get) endpoint from the `id` property in the response . For more information on how to work with Microsoft Graph, try the [Graph Explorer](https://developer.microsoft.com/en-us/graph/graph-explorer?request=users%2F%7Buser-mail%7D&method=GET&version=v1.0&GraphUrl=https://graph.microsoft.com) and look into the [Graph SDK](/graph/sdks/sdks-overview). Alternatively, you can find the ID as the `oid` claim in an [Azure AD ID token](/azure/active-directory/develop/id-tokens#payload-claims) or [Azure AD access token](/azure/active-directory/develop/access-tokens#payload-claims) after your user has signed in and acquired a token.
3939

4040
#### Basic usage
4141

4242
```javascript
43-
// get the Teams user's ID if only the email is known, assuming a helper method
44-
const userId = await getUserIdFromGraph("[email protected]");
43+
// get the Teams user's ID from Graph APIs if only the email is known
44+
const user = await graphClient.api("/users/[email protected]").get();
4545

4646
// create an identifier
47-
const teamsUser = { microsoftTeamsUserId: userId };
47+
const teamsUser = { microsoftTeamsUserId: user.id };
4848

4949
// if you're not operating in the public cloud, you must also pass the right Cloud type.
5050
const gcchTeamsUser = { microsoftTeamsUserId: userId, cloud: "gcch" };

articles/communication-services/concepts/includes/identifiers/identifiers-net.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,18 @@ var sameUser = new CommunicationUserIdentifier(newUserId);
3535

3636
### Microsoft Teams User identifier
3737

38-
The `MicrosoftTeamsUserIdentifier` represents a Teams user with its Azure AD user object ID. You can retrieve the Azure AD user object ID via the [Microsoft Graph REST API /users](/graph/api/user-get) endpoint from the `id` property in the response. Alternatively, you can find the ID as the `oid` claim in an [Azure AD ID token](/azure/active-directory/develop/id-tokens#payload-claims) or [Azure AD access token](/azure/active-directory/develop/access-tokens#payload-claims) after your user has signed in and acquired a token.
38+
The `MicrosoftTeamsUserIdentifier` represents a Teams user with its Azure AD user object ID. You can retrieve the Azure AD user object ID via the [Microsoft Graph REST API /users](/graph/api/user-get) endpoint from the `id` property in the response . For more information on how to work with Microsoft Graph, try the [Graph Explorer](https://developer.microsoft.com/en-us/graph/graph-explorer?request=users%2F%7Buser-mail%7D&method=GET&version=v1.0&GraphUrl=https://graph.microsoft.com) and look into the [Graph SDK](/graph/sdks/sdks-overview). Alternatively, you can find the ID as the `oid` claim in an [Azure AD ID token](/azure/active-directory/develop/id-tokens#payload-claims) or [Azure AD access token](/azure/active-directory/develop/access-tokens#payload-claims) after your user has signed in and acquired a token.
3939

4040
#### Basic usage
4141

4242
```csharp
43-
// get the Teams user's ID if only the email is known, assuming a helper method
44-
string userId = await GetUserIdFromGraph("[email protected]");
43+
// get the Teams user's ID from Graph APIs if only the email is known
44+
var user = await graphClient.Users["[email protected]"]
45+
.Request()
46+
.GetAsync();
4547

4648
// create an identifier
47-
var teamsUser = new MicrosoftTeamsUserIdentifier(userId);
49+
var teamsUser = new MicrosoftTeamsUserIdentifier(user.Id);
4850

4951
// if you're not operating in the public cloud, you must also pass the right Cloud type.
5052
var gcchTeamsUser = new MicrosoftTeamsUserIdentifier(userId: userId, cloud: CommunicationCloudEnvironment.Gcch);

articles/communication-services/concepts/includes/identifiers/identifiers-python.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ same_user = CommunicationUserIdentifier(new_user_id)
3535

3636
### Microsoft Teams User identifier
3737

38-
The `MicrosoftTeamsUserIdentifier` represents a Teams user with its Azure AD user object ID. You can retrieve the Azure AD user object ID via the [Microsoft Graph REST API /users](/graph/api/user-get) endpoint from the `id` property in the response. Alternatively, you can find the ID as the `oid` claim in an [Azure AD ID token](/azure/active-directory/develop/id-tokens#payload-claims) or [Azure AD access token](/azure/active-directory/develop/access-tokens#payload-claims) after your user has signed in and acquired a token.
38+
The `MicrosoftTeamsUserIdentifier` represents a Teams user with its Azure AD user object ID. You can retrieve the Azure AD user object ID via the [Microsoft Graph REST API /users](/graph/api/user-get) endpoint from the `id` property in the response . For more information on how to work with Microsoft Graph, try the [Graph Explorer](https://developer.microsoft.com/en-us/graph/graph-explorer?request=users%2F%7Buser-mail%7D&method=GET&version=v1.0&GraphUrl=https://graph.microsoft.com) and look into the [Graph SDK](/graph/sdks/sdks-overview). Alternatively, you can find the ID as the `oid` claim in an [Azure AD ID token](/azure/active-directory/develop/id-tokens#payload-claims) or [Azure AD access token](/azure/active-directory/develop/access-tokens#payload-claims) after your user has signed in and acquired a token.
3939

4040
#### Basic usage
4141

4242
```python
43-
# get the Teams user's ID if only the email is known, assuming a helper method
44-
user_id = get_userid_from_graph("[email protected]")
43+
# get the Teams user's ID from Graph APIs if only the email is known
44+
user_id = graph_client.get("/users/[email protected]").json().get("id");
4545

4646
# create an identifier
4747
teams_user = MicrosoftTeamsUserIdentifier(user_id)

articles/communication-services/concepts/includes/identifiers/identifiers-rest.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ You can find an example for a request that includes an identifier in Chat's REST
5050

5151
### Microsoft Teams User identifier
5252

53-
The `MicrosoftTeamsUserIdentifierModel` represents a Teams user. You need to know the Teams user's ID that you can retrieve via the [Microsoft Graph REST API /users](/graph/api/user-get) endpoint.
53+
The `MicrosoftTeamsUserIdentifierModel` represents a Teams user with its Azure AD user object ID. You can retrieve the Azure AD user object ID via the [Microsoft Graph REST API /users](/graph/api/user-get) endpoint from the `id` property in the response . For more information on how to work with Microsoft Graph, try the [Graph Explorer](https://developer.microsoft.com/en-us/graph/graph-explorer?request=users%2F%7Buser-mail%7D&method=GET&version=v1.0&GraphUrl=https://graph.microsoft.com) and look into the [Graph SDK](/graph/sdks/sdks-overview). Alternatively, you can find the ID as the `oid` claim in an [Azure AD ID token](/azure/active-directory/develop/id-tokens#payload-claims) or [Azure AD access token](/azure/active-directory/develop/access-tokens#payload-claims) after your user has signed in and acquired a token.
5454

5555
#### Basic usage
5656

@@ -113,7 +113,7 @@ The `PhoneNumberIdentifierModel` represents a phone number. The service assumes
113113
// response
114114
{
115115
"kind": "phoneNumber",
116-
"rawId": "4:112345556789",
116+
"rawId": "4:+112345556789",
117117
"phoneNumber": {
118118
"value": "+112345556789"
119119
}
@@ -269,7 +269,7 @@ The raw ID is the Teams visitor ID prefixed with `8:teamsvisitor:`. The Teams vi
269269
```
270270
*Raw ID:*
271271

272-
`4:1123455567`
272+
`4:+1123455567`
273273

274274
The raw ID is the E.164 formatted phone number without the leading `+` and prefixed with `4:`.
275275

0 commit comments

Comments
 (0)