Skip to content

Commit

Permalink
[Java] Adding Teams.ManageChats to the scope list (#30241)
Browse files Browse the repository at this point in the history
* added Teams.ManageChats to the cte scope list

* updated recordings
  • Loading branch information
AikoBB authored Aug 4, 2022
1 parent 3bcf41a commit 593a0f6
Show file tree
Hide file tree
Showing 78 changed files with 841 additions and 1,490 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

import java.net.MalformedURLException;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.HashSet;
import java.util.concurrent.ExecutionException;

import com.azure.communication.common.CommunicationUserIdentifier;
Expand Down Expand Up @@ -191,7 +191,7 @@ public void deleteUser() {
public void getTokenForTeamsUser() {
CommunicationIdentityClient communicationIdentityClient = createCommunicationIdentityClient();
try {
String teamsUserAadToken = generateTeamsUserAadToken();
String teamsUserAadToken = getTeamsUserAadToken();
// BEGIN: readme-sample-getTokenForTeamsUser
String clientId = "<Client ID of an Azure AD application>";
String userObjectId = "<Object ID of an Azure AD user (Teams User)>";
Expand All @@ -206,20 +206,25 @@ public void getTokenForTeamsUser() {
}

/**
* Sample code for generating an Azure AD access token of a Teams User
* Sample code for getting an Azure AD access token of a Teams User
*/
private static String generateTeamsUserAadToken() throws MalformedURLException, ExecutionException, InterruptedException {
private static String getTeamsUserAadToken() throws MalformedURLException, ExecutionException, InterruptedException {
String teamsUserAadToken = "";
try {
IPublicClientApplication publicClientApplication = PublicClientApplication.builder("<M365_APP_ID>")
.authority("<M365_AAD_AUTHORITY>" + "/" + "<M365_AAD_TENANT>")
.build();
//M365 scopes
Set<String> scopes = Collections.singleton("https://auth.msft.communication.azure.com/VoIP");

// Create request parameters object for acquiring the AAD token and object ID of a Teams user
Set<String> scopes = new HashSet<String>(Arrays.asList(
"https://auth.msft.communication.azure.com/Teams.ManageCalls",
"https://auth.msft.communication.azure.com/Teams.ManageChats"
));
char[] password = "<MSAL_PASSWORD>".toCharArray();
UserNamePasswordParameters userNamePasswordParameters = UserNamePasswordParameters.builder(scopes, "<MSAL_USERNAME>", password)
.build();
Arrays.fill(password, '0');
// Retrieve the AAD token and object ID of a Teams user
IAuthenticationResult result = publicClientApplication.acquireToken(userNamePasswordParameters).get();
teamsUserAadToken = result.accessToken();
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
import org.junit.jupiter.params.provider.Arguments;

import java.net.MalformedURLException;
import java.util.*;
import java.util.Arrays;
import java.util.List;
import java.util.ArrayList;
import java.util.Set;
import java.util.HashSet;
import java.util.Locale;
import java.util.concurrent.ExecutionException;
import java.util.stream.Stream;

Expand All @@ -29,8 +34,6 @@ public class CteTestHelper {
.get("COMMUNICATION_M365_AAD_TENANT", "Sanitized");
private static final String COMMUNICATION_M365_REDIRECT_URI = Configuration.getGlobalConfiguration()
.get("COMMUNICATION_M365_REDIRECT_URI", "Sanitized");
private static final String COMMUNICATION_M365_SCOPE = Configuration.getGlobalConfiguration()
.get("COMMUNICATION_M365_SCOPE", "Sanitized");
private static final String COMMUNICATION_MSAL_USERNAME = Configuration.getGlobalConfiguration()
.get("COMMUNICATION_MSAL_USERNAME", "Sanitized");
private static final String COMMUNICATION_MSAL_PASSWORD = Configuration.getGlobalConfiguration()
Expand Down Expand Up @@ -73,7 +76,10 @@ private static GetTokenForTeamsUserOptions createTeamsUserExchangeTokenRequest()
IPublicClientApplication publicClientApplication = PublicClientApplication.builder(COMMUNICATION_M365_APP_ID)
.authority(COMMUNICATION_M365_AAD_AUTHORITY + "/" + COMMUNICATION_M365_AAD_TENANT)
.build();
Set<String> scopes = Collections.singleton(COMMUNICATION_M365_SCOPE);
Set<String> scopes = new HashSet<String>(Arrays.asList(
"https://auth.msft.communication.azure.com/Teams.ManageCalls",
"https://auth.msft.communication.azure.com/Teams.ManageChats"
));
char[] password = COMMUNICATION_MSAL_PASSWORD.toCharArray();
UserNamePasswordParameters userNamePasswordParameters = UserNamePasswordParameters.builder(scopes, COMMUNICATION_MSAL_USERNAME, password)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"Method" : "POST",
"Uri" : "https://REDACTED.ppe.communication.azure.net/identities?api-version=2022-06-01",
"Headers" : {
"User-Agent" : "azsdk-java-azure-communication-identity/1.2.0-beta.2 (11.0.12; Mac OS X; 12.3.1)",
"x-ms-client-request-id" : "b5df33d0-090a-434d-b4d5-fdc5e5adb101",
"User-Agent" : "azsdk-java-azure-communication-identity/1.3.0-beta.1 (11.0.12; Mac OS X; 12.4)",
"x-ms-client-request-id" : "21539df0-8143-4e78-9e3e-231ca42f5566",
"Content-Type" : "application/json"
},
"Response" : {
Expand All @@ -13,13 +13,13 @@
"api-supported-versions" : "2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07, 2021-10-31-preview, 2021-11-01, 2022-06-01",
"retry-after" : "0",
"StatusCode" : "201",
"Date" : "Tue, 19 Apr 2022 09:05:24 GMT",
"Date" : "Tue, 02 Aug 2022 12:25:32 GMT",
"Strict-Transport-Security" : "max-age=2592000",
"X-Processing-Time" : "362ms",
"MS-CV" : "0iJEKHNVc0iVMKemHWgDKQ.0",
"X-Azure-Ref" : "0U3teYgAAAAAxvI/mD876QIiU3ggRwClhUFJHMDFFREdFMDYxNgBmMDlhNGMxMy0yMWYxLTQ4ZWMtOWNmNy02NjU0NTY4NGI2NDI=",
"X-Processing-Time" : "246ms",
"MS-CV" : "X5q1ZkdDdk61RIPEXOaI9g.0",
"X-Azure-Ref" : "0uxfpYgAAAAAVCWUJqIjpTaIg1Ml8srmUTE9OMjFFREdFMDEwNwBmMDlhNGMxMy0yMWYxLTQ4ZWMtOWNmNy02NjU0NTY4NGI2NDI=",
"Body" : "{\"identity\":{\"id\":\"REDACTED\"}}",
"x-ms-client-request-id" : "b5df33d0-090a-434d-b4d5-fdc5e5adb101",
"x-ms-client-request-id" : "21539df0-8143-4e78-9e3e-231ca42f5566",
"Content-Type" : "application/json; charset=utf-8",
"Request-Context" : "appId="
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"Method" : "POST",
"Uri" : "https://REDACTED.ppe.communication.azure.net/identities?api-version=2022-06-01",
"Headers" : {
"User-Agent" : "azsdk-java-azure-communication-identity/1.2.0-beta.2 (11.0.12; Mac OS X; 12.3.1)",
"x-ms-client-request-id" : "c5a19192-0074-4799-8816-1feee95aea59",
"User-Agent" : "azsdk-java-azure-communication-identity/1.3.0-beta.1 (11.0.12; Mac OS X; 12.4)",
"x-ms-client-request-id" : "1f6c13ff-122c-4190-9e51-75431a77d735",
"Content-Type" : "application/json"
},
"Response" : {
Expand All @@ -13,13 +13,13 @@
"api-supported-versions" : "2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07, 2021-10-31-preview, 2021-11-01, 2022-06-01",
"retry-after" : "0",
"StatusCode" : "201",
"Date" : "Tue, 19 Apr 2022 09:05:24 GMT",
"Date" : "Tue, 02 Aug 2022 12:25:37 GMT",
"Strict-Transport-Security" : "max-age=2592000",
"X-Processing-Time" : "363ms",
"MS-CV" : "6m84zz9Ajkm+hS4Wt2cgxw.0",
"X-Azure-Ref" : "0VHteYgAAAAANlzoONR/hSrfjEOsfgEneUFJHMDFFREdFMDYxOQBmMDlhNGMxMy0yMWYxLTQ4ZWMtOWNmNy02NjU0NTY4NGI2NDI=",
"X-Processing-Time" : "46ms",
"MS-CV" : "sTE/Pm7/0EKcqpaXA9ISsg.0",
"X-Azure-Ref" : "0wRfpYgAAAAA5BAAe9lohQJgrh4M4p4pATE9OMjFFREdFMDEwNwBmMDlhNGMxMy0yMWYxLTQ4ZWMtOWNmNy02NjU0NTY4NGI2NDI=",
"Body" : "{\"identity\":{\"id\":\"REDACTED\"}}",
"x-ms-client-request-id" : "c5a19192-0074-4799-8816-1feee95aea59",
"x-ms-client-request-id" : "1f6c13ff-122c-4190-9e51-75431a77d735",
"Content-Type" : "application/json; charset=utf-8",
"Request-Context" : "appId="
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"Method" : "POST",
"Uri" : "https://REDACTED.ppe.communication.azure.net/identities?api-version=2022-06-01",
"Headers" : {
"User-Agent" : "azsdk-java-azure-communication-identity/1.2.0-beta.2 (11.0.12; Mac OS X; 12.3.1)",
"x-ms-client-request-id" : "6f677c75-159b-4972-a612-e0867eb4a81a",
"User-Agent" : "azsdk-java-azure-communication-identity/1.3.0-beta.1 (11.0.12; Mac OS X; 12.4)",
"x-ms-client-request-id" : "d2a7eef8-2a43-4484-8dfa-bb637fd8e0f1",
"Content-Type" : "application/json"
},
"Response" : {
Expand All @@ -13,13 +13,13 @@
"api-supported-versions" : "2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07, 2021-10-31-preview, 2021-11-01, 2022-06-01",
"retry-after" : "0",
"StatusCode" : "201",
"Date" : "Tue, 19 Apr 2022 09:05:24 GMT",
"Date" : "Tue, 02 Aug 2022 12:25:40 GMT",
"Strict-Transport-Security" : "max-age=2592000",
"X-Processing-Time" : "28ms",
"MS-CV" : "bkPEmdMz4UidlszhjmAmKQ.0",
"X-Azure-Ref" : "0VHteYgAAAAAe3JycUipuRaTxOZnWq75dUFJHMDFFREdFMDcwOQBmMDlhNGMxMy0yMWYxLTQ4ZWMtOWNmNy02NjU0NTY4NGI2NDI=",
"MS-CV" : "DhohsPKVnUWi7myr/NH1eA.0",
"X-Azure-Ref" : "0xBfpYgAAAABVHw6mvbopTLKnFDLwsUpxTE9OMjFFREdFMDEwNwBmMDlhNGMxMy0yMWYxLTQ4ZWMtOWNmNy02NjU0NTY4NGI2NDI=",
"Body" : "{\"identity\":{\"id\":\"REDACTED\"}}",
"x-ms-client-request-id" : "6f677c75-159b-4972-a612-e0867eb4a81a",
"x-ms-client-request-id" : "d2a7eef8-2a43-4484-8dfa-bb637fd8e0f1",
"Content-Type" : "application/json; charset=utf-8",
"Request-Context" : "appId="
},
Expand All @@ -28,20 +28,20 @@
"Method" : "DELETE",
"Uri" : "https://REDACTED.ppe.communication.azure.net/identities/REDACTED?api-version=2022-06-01",
"Headers" : {
"User-Agent" : "azsdk-java-azure-communication-identity/1.2.0-beta.2 (11.0.12; Mac OS X; 12.3.1)",
"x-ms-client-request-id" : "4722c61f-339e-4c2f-826b-78e59bfd8a1a"
"User-Agent" : "azsdk-java-azure-communication-identity/1.3.0-beta.1 (11.0.12; Mac OS X; 12.4)",
"x-ms-client-request-id" : "0bb4c114-f8ee-4c86-88c3-b03ab5dff49b"
},
"Response" : {
"X-Cache" : "CONFIG_NOCACHE",
"Strict-Transport-Security" : "max-age=2592000",
"api-supported-versions" : "2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07, 2021-10-31-preview, 2021-11-01, 2022-06-01",
"X-Processing-Time" : "92ms",
"MS-CV" : "CSG5sKkq80WXN1Iu8YELaw.0",
"X-Processing-Time" : "159ms",
"MS-CV" : "czSzpTvT1kashTXMuq5OZA.0",
"retry-after" : "0",
"X-Azure-Ref" : "0VHteYgAAAAAhOTpruZJVRLYwWf8nEWs0UFJHMDFFREdFMDkwNgBmMDlhNGMxMy0yMWYxLTQ4ZWMtOWNmNy02NjU0NTY4NGI2NDI=",
"X-Azure-Ref" : "0xBfpYgAAAAB2bc9vevgiRqlYsqjgfvPhTE9OMjFFREdFMDIxMQBmMDlhNGMxMy0yMWYxLTQ4ZWMtOWNmNy02NjU0NTY4NGI2NDI=",
"StatusCode" : "204",
"x-ms-client-request-id" : "4722c61f-339e-4c2f-826b-78e59bfd8a1a",
"Date" : "Tue, 19 Apr 2022 09:05:24 GMT",
"x-ms-client-request-id" : "0bb4c114-f8ee-4c86-88c3-b03ab5dff49b",
"Date" : "Tue, 02 Aug 2022 12:25:40 GMT",
"Request-Context" : "appId="
},
"Exception" : null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"Method" : "POST",
"Uri" : "https://REDACTED.ppe.communication.azure.net/identities?api-version=2022-06-01",
"Headers" : {
"User-Agent" : "azsdk-java-azure-communication-identity/1.2.0-beta.2 (11.0.12; Mac OS X; 12.3.1)",
"x-ms-client-request-id" : "ceb074cd-419e-45ec-8967-a01e2aa4ef5d",
"User-Agent" : "azsdk-java-azure-communication-identity/1.3.0-beta.1 (11.0.12; Mac OS X; 12.4)",
"x-ms-client-request-id" : "1aca1d0c-c29a-4cf3-8a91-8c6ec4f7cc05",
"Content-Type" : "application/json"
},
"Response" : {
Expand All @@ -13,13 +13,13 @@
"api-supported-versions" : "2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07, 2021-10-31-preview, 2021-11-01, 2022-06-01",
"retry-after" : "0",
"StatusCode" : "201",
"Date" : "Tue, 19 Apr 2022 09:05:23 GMT",
"Date" : "Tue, 02 Aug 2022 12:25:39 GMT",
"Strict-Transport-Security" : "max-age=2592000",
"X-Processing-Time" : "66ms",
"MS-CV" : "AFiAH36tJkOll6gU45K7Zw.0",
"X-Azure-Ref" : "0VHteYgAAAABwv+Ojb5YjQJ1cX1J34DiUUFJHMDFFREdFMDYxOABmMDlhNGMxMy0yMWYxLTQ4ZWMtOWNmNy02NjU0NTY4NGI2NDI=",
"X-Processing-Time" : "45ms",
"MS-CV" : "/w0xNCuhak+BMc7auV61oQ.0",
"X-Azure-Ref" : "0wxfpYgAAAACmib3WAuV9TZGRlevXbtaTTE9OMjFFREdFMDEwNwBmMDlhNGMxMy0yMWYxLTQ4ZWMtOWNmNy02NjU0NTY4NGI2NDI=",
"Body" : "{\"identity\":{\"id\":\"REDACTED\"}}",
"x-ms-client-request-id" : "ceb074cd-419e-45ec-8967-a01e2aa4ef5d",
"x-ms-client-request-id" : "1aca1d0c-c29a-4cf3-8a91-8c6ec4f7cc05",
"Content-Type" : "application/json; charset=utf-8",
"Request-Context" : "appId="
},
Expand All @@ -28,20 +28,20 @@
"Method" : "DELETE",
"Uri" : "https://REDACTED.ppe.communication.azure.net/identities/REDACTED?api-version=2022-06-01",
"Headers" : {
"User-Agent" : "azsdk-java-azure-communication-identity/1.2.0-beta.2 (11.0.12; Mac OS X; 12.3.1)",
"x-ms-client-request-id" : "385db1d1-307e-458c-9c2d-c43f1845e03d"
"User-Agent" : "azsdk-java-azure-communication-identity/1.3.0-beta.1 (11.0.12; Mac OS X; 12.4)",
"x-ms-client-request-id" : "f5788dfa-977e-4e94-a0c0-ea0104b5aa69"
},
"Response" : {
"X-Cache" : "CONFIG_NOCACHE",
"Strict-Transport-Security" : "max-age=2592000",
"api-supported-versions" : "2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07, 2021-10-31-preview, 2021-11-01, 2022-06-01",
"X-Processing-Time" : "97ms",
"MS-CV" : "gu2Ln7cQFUaDtSJJSumoDQ.0",
"X-Processing-Time" : "158ms",
"MS-CV" : "rXgSdNIMOkGLpW44DiM5ow.0",
"retry-after" : "0",
"X-Azure-Ref" : "0VHteYgAAAAAtAGUaQgbcTo3VCAqci3oZUFJHMDFFREdFMDcxOABmMDlhNGMxMy0yMWYxLTQ4ZWMtOWNmNy02NjU0NTY4NGI2NDI=",
"X-Azure-Ref" : "0wxfpYgAAAAD6zcpjdp/NQ7TG+TLbov3KTE9OMjFFREdFMDIxMQBmMDlhNGMxMy0yMWYxLTQ4ZWMtOWNmNy02NjU0NTY4NGI2NDI=",
"StatusCode" : "204",
"x-ms-client-request-id" : "385db1d1-307e-458c-9c2d-c43f1845e03d",
"Date" : "Tue, 19 Apr 2022 09:05:23 GMT",
"x-ms-client-request-id" : "f5788dfa-977e-4e94-a0c0-ea0104b5aa69",
"Date" : "Tue, 02 Aug 2022 12:25:39 GMT",
"Request-Context" : "appId="
},
"Exception" : null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"Method" : "POST",
"Uri" : "https://REDACTED.ppe.communication.azure.net/identities?api-version=2022-06-01",
"Headers" : {
"User-Agent" : "azsdk-java-azure-communication-identity/1.2.0-beta.2 (11.0.12; Mac OS X; 12.3.1)",
"x-ms-client-request-id" : "bc94e54d-b923-4b0c-89ab-75a6fa3ad935",
"User-Agent" : "azsdk-java-azure-communication-identity/1.3.0-beta.1 (11.0.12; Mac OS X; 12.4)",
"x-ms-client-request-id" : "27880c83-b1fc-478a-a920-077537bdafe5",
"Content-Type" : "application/json"
},
"Response" : {
Expand All @@ -13,13 +13,13 @@
"api-supported-versions" : "2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07, 2021-10-31-preview, 2021-11-01, 2022-06-01",
"retry-after" : "0",
"StatusCode" : "201",
"Date" : "Tue, 19 Apr 2022 09:05:24 GMT",
"Date" : "Tue, 02 Aug 2022 12:25:41 GMT",
"Strict-Transport-Security" : "max-age=2592000",
"X-Processing-Time" : "29ms",
"MS-CV" : "Q1zV40s7cE2xiWAbX4BrVg.0",
"X-Azure-Ref" : "0VHteYgAAAADZmNN/8mE0TKnA6IDDFKCYUFJHMDFFREdFMDkwOABmMDlhNGMxMy0yMWYxLTQ4ZWMtOWNmNy02NjU0NTY4NGI2NDI=",
"X-Processing-Time" : "31ms",
"MS-CV" : "Pu+YQ4wZhkaUol1VTwwpeA.0",
"X-Azure-Ref" : "0xRfpYgAAAAB663ngXlnFQ6dCjJOCWLW/TE9OMjFFREdFMDEwNwBmMDlhNGMxMy0yMWYxLTQ4ZWMtOWNmNy02NjU0NTY4NGI2NDI=",
"Body" : "{\"identity\":{\"id\":\"REDACTED\"}}",
"x-ms-client-request-id" : "bc94e54d-b923-4b0c-89ab-75a6fa3ad935",
"x-ms-client-request-id" : "27880c83-b1fc-478a-a920-077537bdafe5",
"Content-Type" : "application/json; charset=utf-8",
"Request-Context" : "appId="
},
Expand All @@ -28,23 +28,23 @@
"Method" : "POST",
"Uri" : "https://REDACTED.ppe.communication.azure.net/identities/REDACTED/:issueAccessToken?api-version=2022-06-01",
"Headers" : {
"User-Agent" : "azsdk-java-azure-communication-identity/1.2.0-beta.2 (11.0.12; Mac OS X; 12.3.1)",
"x-ms-client-request-id" : "9b5a3a58-b7ff-4b80-ba14-93b1359d25ef",
"User-Agent" : "azsdk-java-azure-communication-identity/1.3.0-beta.1 (11.0.12; Mac OS X; 12.4)",
"x-ms-client-request-id" : "22443ea7-15e4-46d0-8904-427336d1f554",
"Content-Type" : "application/json"
},
"Response" : {
"X-Cache" : "CONFIG_NOCACHE",
"content-length" : "804",
"content-length" : "803",
"api-supported-versions" : "2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07, 2021-10-31-preview, 2021-11-01, 2022-06-01",
"retry-after" : "0",
"StatusCode" : "200",
"Date" : "Tue, 19 Apr 2022 09:05:25 GMT",
"Date" : "Tue, 02 Aug 2022 12:25:41 GMT",
"Strict-Transport-Security" : "max-age=2592000",
"X-Processing-Time" : "444ms",
"MS-CV" : "ZxfqEtgctUiXo1FMxhVlig.0",
"X-Azure-Ref" : "0VHteYgAAAAAPXyDQOPD3TrxQ4U3QuFKOUFJHMDFFREdFMDcxNwBmMDlhNGMxMy0yMWYxLTQ4ZWMtOWNmNy02NjU0NTY4NGI2NDI=",
"Body" : "{\"token\":\"REDACTED\",\"expiresOn\":\"2022-04-20T09:05:25.6915334+00:00\"}",
"x-ms-client-request-id" : "9b5a3a58-b7ff-4b80-ba14-93b1359d25ef",
"X-Processing-Time" : "36ms",
"MS-CV" : "VbZLzV0UEEOjvRwiAsZ4iA.0",
"X-Azure-Ref" : "0xRfpYgAAAADCDhi0+DzUSKYWIGDVP6dsTE9OMjFFREdFMDIxMQBmMDlhNGMxMy0yMWYxLTQ4ZWMtOWNmNy02NjU0NTY4NGI2NDI=",
"Body" : "{\"token\":\"REDACTED\",\"expiresOn\":\"2022-08-03T12:25:41.335856+00:00\"}",
"x-ms-client-request-id" : "22443ea7-15e4-46d0-8904-427336d1f554",
"Content-Type" : "application/json; charset=utf-8",
"Request-Context" : "appId="
},
Expand Down
Loading

0 comments on commit 593a0f6

Please sign in to comment.