You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Finally, the Common library includes a CommunicationAccessKeyCredentialPolicy that uses a custom documented HMAC scheme for signing the request and providing the signature on the Authorization header.
HMAC auth is used for the Communication SMS and Administration libraries, user auth is used for the Communication Chat and Calling libraries where all requests get sent on behalf of a single user.
Managed identities
We have recently added support for Managed Identities as well.
Communication user directory
Azure Communication Services supports a Bring-Your-Own-Identity scheme that isn't tied to identity providers such as Active Directory. The Communication Administration library and service provide a simple API to
create and delete a communication user
issue and revoke tokens for a user
The developer has to store a mapping between Communication user ids and their own identity models. It is up to the developer to manage the lifetime of a communication user, whether for long-lived scenarios (employee or customer directory) or for short-lived scenarios (a customer support chat, contact your delivery person).
User access token auth
The Common library further includes a CommunicationTokenCredential which is a wrapper around a Communication Service access token and provides auto-refresh mechanics. The developer can provide a callback that the credential then uses to request a new token. If a callback is provided, the credential will use the callback on-demand if the token has expired. Additionally, the developer can opt-in to refresh proactively. With proactive refresh, the credential uses a timer mechanism to request a new token before expiry. The user scenario for proactive refresh is connection stability where waiting for a token roundtrip could cause dropping calls.
Developer flow to issue user access tokens
A typical flow involves the developer to implement their own server route to issue tokens. This route is guarded by whatever auth and identity mechanism the developer already uses, for example Google accounts or their own identity implementation. Then once authenticated, the route controller uses the Communication Administration library to issue a new Communication user access token and pass it down to the client. The client uses the token to instantiate or refresh the CommunicationTokenCredential.
The Communication Common library includes common types for identifiers that are used with the Communication libraries, for example phone numbers, calling applications or communication users. We expect the list of identifiers to grow over time, Microsoft Teams user types will be added soon.
Identifiers are a developer friendly model that hides the IC3 internal concept of a generic MRI (message resource identifier) in favor of a pre-defined set of different concrete types.
A champion scenario is a use case that the consumer of the client library is commonly expected to perform. Champion scenarios are used to ensure the developer experience is exemplary for the common cases. You need to show the entire code sample (including error handling, as an example) for the champion scenarios.
Champion Scenario 1: Use CommunicationIdentityClient to create CommunicationUser and issue token
C#
stringconnectionString="CONNECTION_STRING";CommunicationIdentityClientidentityClient=newCommunicationIdentityClient(connectionString);Response<CommunicationUser>communicationUser=awaitidentityClient.CreateUserAsync();CommunicationUserTokencommunicationUserToken=awaitidentityClient.GetTokenAsync(communicationUser:communicationUser.Value,scopes:new[]{CommunicationTokenScope.Chat});Console.WriteLine($"Communication User Id: {communicationUser.Value.Id}");Console.WriteLine($"Communication User Issued Token Value: {communicationUserToken.Token}");
TypeScript
constidentityClient=newCommunicationIdentityClient("CONNECTION_STRING");constuser=awaitidentityClient.createUser();consttoken=awaitidentityClient.getToken(user,["chat"]);console.log("Communication user id: ",user.communicationUserId);console.log("Communication user token: ",token.token);
Champion Scenario 2B: Token from Callback With Proactive Refresh
C#
usingvaruserCredential=newCommunicationUserCredential(refreshProactively:true,// Indicates if the token should be proactively refreshed in the background or only on-demandtokenRefresher: cancellationToken =>FetchTokenForUserFromMyServer("[email protected]",cancellationToken),asyncTokenRefresher: cancellationToken =>FetchTokenForUserFromMyServerAsync("[email protected]",cancellationToken));awaituserCredential.GetTokenAsync();ChatClientchatClient=newChatClient(newUri(endpoint),userCredential);
PagedIterable<ChatThreadMember> chatThreadMembersResponse = chatThreadClient.listMembers();
chatThreadMembersResponse.iterableByPage().forEach(resp -> {
resp.getItems().forEach(chatMember -> {
System.out.printf("Member id is %s.", chatMember.getUser().getId());
});
});
Swift
chatClient.listChatThreadParticipants(chatThreadId:"SomeChatThreadId"){(result, httpResponse)in
switch result {caselet.success(pages):
guard let items = pages.items else{print("Failed to get members back for this thread id")return}
if items.count >0{
pages.forEachItem{(member)->Boolin
guard let name = participant.displayName else{print("Chat participanthas has no display name")return false
}print("Chat participant's display name is: \(name)")return true
}}case.failure:print("Failed to get members back for this thread id")}}
The text was updated successfully, but these errors were encountered:
RezaJooyandeh
changed the title
Board Review: Azure Communication Services (SPOOL) - Authentication
Board Review: Azure Communication Services (SPOOL) - Authentication (Identity and Common packages)
Feb 19, 2021
The Basics
About this client library
Access key HMAC auth
Finally, the Common library includes a
CommunicationAccessKeyCredentialPolicy
that uses a custom documented HMAC scheme for signing the request and providing the signature on the Authorization header.HMAC auth is used for the Communication SMS and Administration libraries, user auth is used for the Communication Chat and Calling libraries where all requests get sent on behalf of a single user.
Managed identities
We have recently added support for Managed Identities as well.
Communication user directory
Azure Communication Services supports a Bring-Your-Own-Identity scheme that isn't tied to identity providers such as Active Directory. The Communication Administration library and service provide a simple API to
The developer has to store a mapping between Communication user ids and their own identity models. It is up to the developer to manage the lifetime of a communication user, whether for long-lived scenarios (employee or customer directory) or for short-lived scenarios (a customer support chat, contact your delivery person).
User access token auth
The Common library further includes a
CommunicationTokenCredential
which is a wrapper around a Communication Service access token and provides auto-refresh mechanics. The developer can provide a callback that the credential then uses to request a new token. If a callback is provided, the credential will use the callback on-demand if the token has expired. Additionally, the developer can opt-in to refresh proactively. With proactive refresh, the credential uses a timer mechanism to request a new token before expiry. The user scenario for proactive refresh is connection stability where waiting for a token roundtrip could cause dropping calls.Developer flow to issue user access tokens
A typical flow involves the developer to implement their own server route to issue tokens. This route is guarded by whatever auth and identity mechanism the developer already uses, for example Google accounts or their own identity implementation. Then once authenticated, the route controller uses the Communication Administration library to issue a new Communication user access token and pass it down to the client. The client uses the token to instantiate or refresh the
CommunicationTokenCredential
.Docs for building a token issuer service with Azure Functions
Identifier types
The Communication Common library includes common types for identifiers that are used with the Communication libraries, for example phone numbers, calling applications or communication users. We expect the list of identifiers to grow over time, Microsoft Teams user types will be added soon.
Identifiers are a developer friendly model that hides the IC3 internal concept of a generic
MRI
(message resource identifier) in favor of a pre-defined set of different concrete types.Artifacts required (per language)
_shared
folder of other packages)Champion scenarios
A champion scenario is a use case that the consumer of the client library is commonly expected to perform. Champion scenarios are used to ensure the developer experience is exemplary for the common cases. You need to show the entire code sample (including error handling, as an example) for the champion scenarios.
Champion Scenario 1: Use
CommunicationIdentityClient
to createCommunicationUser
and issue tokenC#
TypeScript
Java
Champion Scenario 2: Create
CommunicationTokenCredential
to provide user tokens in other clients likeChatClient
Champion Scenario 2A: Get Token String
C#
TypeScript
Java
Swift
Champion Scenario 2B: Token from Callback With Proactive Refresh
C#
TypeScript
Champion Scenario 3: Communication Identifiers appearing in other Clients like Chat
C#
TypeScript
Java
Swift
The text was updated successfully, but these errors were encountered: