CommunicationIdentityClient class

Client class for interacting with Azure Communication Services User Token Management.

Constructors

CommunicationIdentityClient(string, CommunicationIdentityClientOptions)

Initializes a new instance of the CommunicationIdentity class.

CommunicationIdentityClient(string, KeyCredential, CommunicationIdentityClientOptions)

Initializes a new instance of the CommunicationIdentity class using an Azure KeyCredential.

CommunicationIdentityClient(string, TokenCredential, CommunicationIdentityClientOptions)

Initializes a new instance of the CommunicationIdentity class using a TokenCredential.

Methods

createUser(OperationOptions)

Creates a single user.

createUserAndToken(TokenScope[], CreateUserAndTokenOptions)

Creates a single user and a token simultaneously.

deleteUser(CommunicationUserIdentifier, OperationOptions)

Triggers revocation event for user and deletes all its data.

getToken(CommunicationUserIdentifier, TokenScope[], GetTokenOptions)

Creates a scoped user token.

getTokenForTeamsUser(GetTokenForTeamsUserOptions)

Exchanges an Azure AD access token of a Teams user for a new Communication Identity access token with a matching expiration time.

revokeTokens(CommunicationUserIdentifier, OperationOptions)

Revokes all data and tokens created for a user.

Constructor Details

CommunicationIdentityClient(string, CommunicationIdentityClientOptions)

Initializes a new instance of the CommunicationIdentity class.

new CommunicationIdentityClient(connectionString: string, options?: CommunicationIdentityClientOptions)

Parameters

connectionString

string

Connection string to connect to an Azure Communication Service resource. Example: "endpoint=https://contoso.eastus.communications.azure.net/;accesskey=secret";

options
CommunicationIdentityClientOptions

Optional. Options to configure the HTTP pipeline.

CommunicationIdentityClient(string, KeyCredential, CommunicationIdentityClientOptions)

Initializes a new instance of the CommunicationIdentity class using an Azure KeyCredential.

new CommunicationIdentityClient(endpoint: string, credential: KeyCredential, options?: CommunicationIdentityClientOptions)

Parameters

endpoint

string

The endpoint of the service (ex: https://contoso.eastus.communications.azure.net).

credential
KeyCredential

An object that is used to authenticate requests to the service. Use the AzureKeyCredential or @azure/identity to create a credential.

options
CommunicationIdentityClientOptions

Optional. Options to configure the HTTP pipeline.

CommunicationIdentityClient(string, TokenCredential, CommunicationIdentityClientOptions)

Initializes a new instance of the CommunicationIdentity class using a TokenCredential.

new CommunicationIdentityClient(endpoint: string, credential: TokenCredential, options?: CommunicationIdentityClientOptions)

Parameters

endpoint

string

The endpoint of the service (ex: https://contoso.eastus.communications.azure.net)

credential
TokenCredential

TokenCredential that is used to authenticate requests to the service.

options
CommunicationIdentityClientOptions

Optional. Options to configure the HTTP pipeline.

Method Details

createUser(OperationOptions)

Creates a single user.

function createUser(options?: OperationOptions): Promise<CommunicationUserIdentifier>

Parameters

options
OperationOptions

Additional options for the request.

Returns

createUserAndToken(TokenScope[], CreateUserAndTokenOptions)

Creates a single user and a token simultaneously.

function createUserAndToken(scopes: TokenScope[], options?: CreateUserAndTokenOptions): Promise<CommunicationUserToken>

Parameters

scopes

TokenScope[]

Scopes to include in the token.

options
CreateUserAndTokenOptions

Additional options for the request.

Returns

deleteUser(CommunicationUserIdentifier, OperationOptions)

Triggers revocation event for user and deletes all its data.

function deleteUser(user: CommunicationUserIdentifier, options?: OperationOptions): Promise<void>

Parameters

user
CommunicationUserIdentifier

The user being deleted.

options
OperationOptions

Additional options for the request.

Returns

Promise<void>

getToken(CommunicationUserIdentifier, TokenScope[], GetTokenOptions)

Creates a scoped user token.

function getToken(user: CommunicationUserIdentifier, scopes: TokenScope[], options?: GetTokenOptions): Promise<CommunicationAccessToken>

Parameters

user
CommunicationUserIdentifier

The user whose tokens are being issued.

scopes

TokenScope[]

Scopes to include in the token.

options
GetTokenOptions

Additional options for the request.

Returns

getTokenForTeamsUser(GetTokenForTeamsUserOptions)

Exchanges an Azure AD access token of a Teams user for a new Communication Identity access token with a matching expiration time.

function getTokenForTeamsUser(options: GetTokenForTeamsUserOptions): Promise<CommunicationAccessToken>

Parameters

options
GetTokenForTeamsUserOptions

Options used to exchange an Azure AD access token of a Teams user for a new Communication Identity access token.

Returns

revokeTokens(CommunicationUserIdentifier, OperationOptions)

Revokes all data and tokens created for a user.

function revokeTokens(user: CommunicationUserIdentifier, options?: OperationOptions): Promise<void>

Parameters

user
CommunicationUserIdentifier

The user whose tokens are being revoked.

options
OperationOptions

Additional options for the request.

Returns

Promise<void>