Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename method ExchangeTeamsToken to ExchangeTeamsUserAadToken #24846

Merged
merged 6 commits into from
Oct 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sdk/communication/Azure.Communication.Identity/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ Response deleteResponse = client.DeleteUser(user);
### Exchanging AAD access token of a Teams User for a Communication Identity access token

```C# Snippet:ExchangeTeamsTokenAsync
Response<AccessToken> tokenResponse = await client.ExchangeTeamsTokenAsync(teamsToken);
Response<AccessToken> tokenResponse = await client.ExchangeTeamsUserAadTokenAsync(teamsToken);
string token = tokenResponse.Value.Token;
Console.WriteLine($"Token: {token}");
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ public CommunicationIdentityClient(System.Uri endpoint, Azure.Core.TokenCredenti
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Communication.CommunicationUserIdentifier>> CreateUserAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Response DeleteUser(Azure.Communication.CommunicationUserIdentifier communicationUser, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response> DeleteUserAsync(Azure.Communication.CommunicationUserIdentifier communicationUser, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Response<Azure.Core.AccessToken> ExchangeTeamsToken(string teamsToken, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Core.AccessToken>> ExchangeTeamsTokenAsync(string teamsToken, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Response<Azure.Core.AccessToken> ExchangeTeamsUserAadToken(string teamsUserAadToken, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Core.AccessToken>> ExchangeTeamsUserAadTokenAsync(string teamsUserAadToken, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Response<Azure.Core.AccessToken> GetToken(Azure.Communication.CommunicationUserIdentifier communicationUser, System.Collections.Generic.IEnumerable<Azure.Communication.Identity.CommunicationTokenScope> scopes, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Core.AccessToken>> GetTokenAsync(Azure.Communication.CommunicationUserIdentifier communicationUser, System.Collections.Generic.IEnumerable<Azure.Communication.Identity.CommunicationTokenScope> scopes, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Response RevokeTokens(Azure.Communication.CommunicationUserIdentifier communicationUser, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Console.WriteLine($"Expires On: {expiresOn}");
The `CommunicationIdentityClient` can be used to exchange an AAD access token of a Teams user for a new Communication Identity access token with a matching expiration time.

```C# Snippet:ExchangeTeamsToken
Response<AccessToken> tokenResponse = client.ExchangeTeamsToken(teamsToken);
Response<AccessToken> tokenResponse = client.ExchangeTeamsUserAadToken(teamsToken);
string token = tokenResponse.Value.Token;
Console.WriteLine($"Token: {token}");
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Console.WriteLine($"Expires On: {expiresOn}");
The `CommunicationIdentityClient` can be used to exchange an AAD access token of a Teams user for a new Communication Identity access token with a matching expiration time.

```C# Snippet:ExchangeTeamsTokenAsync
Response<AccessToken> tokenResponse = await client.ExchangeTeamsTokenAsync(teamsToken);
Response<AccessToken> tokenResponse = await client.ExchangeTeamsUserAadTokenAsync(teamsToken);
string token = tokenResponse.Value.Token;
Console.WriteLine($"Token: {token}");
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,16 +282,16 @@ public virtual async Task<Response> RevokeTokensAsync(CommunicationUserIdentifie
}

/// <summary>Exchange an AAD access token of a Teams User for a Communication Identity access token.</summary>
/// <param name="teamsToken">AAD access token of a Teams User to acquire a new Communication Identity access token.</param>
/// <param name="teamsUserAadToken">AAD access token of a Teams User to acquire a new Communication Identity access token.</param>
/// <param name="cancellationToken">The cancellation token to use.</param>
/// <exception cref="RequestFailedException">The server returned an error.</exception>
public virtual Response<AccessToken> ExchangeTeamsToken(string teamsToken, CancellationToken cancellationToken = default)
public virtual Response<AccessToken> ExchangeTeamsUserAadToken(string teamsUserAadToken, CancellationToken cancellationToken = default)
{
using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CommunicationIdentityClient)}.{nameof(ExchangeTeamsToken)}");
using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CommunicationIdentityClient)}.{nameof(ExchangeTeamsUserAadToken)}");
scope.Start();
try
{
Response<CommunicationIdentityAccessToken> response = RestClient.ExchangeTeamsUserAccessToken(teamsToken, cancellationToken);
Response<CommunicationIdentityAccessToken> response = RestClient.ExchangeTeamsUserAccessToken(teamsUserAadToken, cancellationToken);
return Response.FromValue(new AccessToken(response.Value.Token, response.Value.ExpiresOn), response.GetRawResponse());
}
catch (Exception ex)
Expand All @@ -302,15 +302,15 @@ public virtual Response<AccessToken> ExchangeTeamsToken(string teamsToken, Cance
}

/// <summary>Asynchronously exchange an AAD access token of a Teams User for a Communication Identity access token.</summary>
/// <param name="teamsToken">AAD access token of a Teams User to acquire a new Communication Identity access token.</param>
/// <param name="teamsUserAadToken">AAD access token of a Teams User to acquire a new Communication Identity access token.</param>
/// <param name="cancellationToken">The cancellation token to use.</param>
public virtual async Task<Response<AccessToken>> ExchangeTeamsTokenAsync(String teamsToken, CancellationToken cancellationToken = default)
public virtual async Task<Response<AccessToken>> ExchangeTeamsUserAadTokenAsync(String teamsUserAadToken, CancellationToken cancellationToken = default)
{
using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CommunicationIdentityClient)}.{nameof(ExchangeTeamsToken)}");
using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CommunicationIdentityClient)}.{nameof(ExchangeTeamsUserAadToken)}");
scope.Start();
try
{
Response<CommunicationIdentityAccessToken> response = await RestClient.ExchangeTeamsUserAccessTokenAsync(teamsToken, cancellationToken).ConfigureAwait(false);
Response<CommunicationIdentityAccessToken> response = await RestClient.ExchangeTeamsUserAccessTokenAsync(teamsUserAadToken, cancellationToken).ConfigureAwait(false);
return Response.FromValue(new AccessToken(response.Value.Token, response.Value.ExpiresOn), response.GetRawResponse());
}
catch (Exception ex)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public async Task RevokeTokenWithNullUserShouldThrow()
}

[Test]
public async Task ExchangeTeamsTokenWithValidToken()
public async Task ExchangeTeamsUserAadTokenWithValidToken()
{
if (TestEnvironment.ShouldIgnoreIdentityExchangeTokenTest) {
Assert.Ignore("Ignore exchange teams token test if flag is enabled.");
Expand All @@ -140,18 +140,18 @@ public async Task ExchangeTeamsTokenWithValidToken()
string token = await generateTeamsToken();

CommunicationIdentityClient client = CreateClientWithConnectionString();
Response<AccessToken> tokenResponse = await client.ExchangeTeamsTokenAsync(token);
Response<AccessToken> tokenResponse = await client.ExchangeTeamsUserAadTokenAsync(token);
Assert.IsNotNull(tokenResponse.Value);
Assert.IsFalse(string.IsNullOrWhiteSpace(tokenResponse.Value.Token));
}

[Test]
public async Task ExchangeTeamsTokenWithEmptyTokenShouldThrow()
public async Task ExchangeTeamsUserAadTokenWithEmptyTokenShouldThrow()
{
try
{
CommunicationIdentityClient client = CreateClientWithConnectionString();
Response<AccessToken> tokenResponse = await client.ExchangeTeamsTokenAsync("");
Response<AccessToken> tokenResponse = await client.ExchangeTeamsUserAadTokenAsync("");
}
catch (RequestFailedException ex)
{
Expand All @@ -164,12 +164,12 @@ public async Task ExchangeTeamsTokenWithEmptyTokenShouldThrow()
}

[Test]
public async Task ExchangeTeamsTokenWithNullTokenShouldThrow()
public async Task ExchangeTeamsUserAadTokenWithNullTokenShouldThrow()
{
try
{
CommunicationIdentityClient client = CreateClientWithConnectionString();
Response<AccessToken> tokenResponse = await client.ExchangeTeamsTokenAsync(null);
Response<AccessToken> tokenResponse = await client.ExchangeTeamsUserAadTokenAsync(null);
}
catch (ArgumentNullException ex)
{
Expand All @@ -180,12 +180,12 @@ public async Task ExchangeTeamsTokenWithNullTokenShouldThrow()
}

[Test]
public async Task ExchangeTeamsTokenWithInvalidTokenShouldThrow()
public async Task ExchangeTeamsUserAadTokenWithInvalidTokenShouldThrow()
{
try
{
CommunicationIdentityClient client = CreateClientWithConnectionString();
Response<AccessToken> tokenResponse = await client.ExchangeTeamsTokenAsync("invalid");
Response<AccessToken> tokenResponse = await client.ExchangeTeamsUserAadTokenAsync("invalid");
}
catch (RequestFailedException ex)
{
Expand All @@ -198,12 +198,12 @@ public async Task ExchangeTeamsTokenWithInvalidTokenShouldThrow()
}

[Test]
public async Task ExchangeTeamsTokenWithExpiredTokenShouldThrow()
public async Task ExchangeTeamsUserAadTokenWithExpiredTokenShouldThrow()
{
try
{
CommunicationIdentityClient client = CreateClientWithConnectionString();
Response<AccessToken> tokenResponse = await client.ExchangeTeamsTokenAsync(TestEnvironment.CommunicationExpiredTeamsToken);
Response<AccessToken> tokenResponse = await client.ExchangeTeamsUserAadTokenAsync(TestEnvironment.CommunicationExpiredTeamsToken);
}
catch (RequestFailedException ex)
{
Expand Down

This file was deleted.

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading