[BUG] ChatThreadClient.AddParticipantAsync always returns forbidden
See original GitHub issueLibrary name and version
Azure.Communication.Chat
Describe the bug
I’m trying to add a user to the chat thread whenever he enters an endpoint on my client application that triggers an api call that creates a record on a db saving his userid and token to be able to enters the room call and eventually the chat.
On client I’m using the UI library for ACS in React, but the problem triggers on backend. Backend: NET CORE 7 + Entity Framework
classeVirtualeEntity.ChatThreadId = the threadId saved on the entity on my database
IEnumerable<CommunicationTokenScope> scopes = new List<CommunicationTokenScope>
{
new CommunicationTokenScope("voip"),
new CommunicationTokenScope("chat")
};
Response<CommunicationUserIdentifierAndToken> tokenResponse = await _identityClient.CreateUserAndTokenAsync(scopes);
CommunicationTokenCredential chatTokenCredentials = new(tokenResponse.Value.AccessToken.Token);
ChatClient chatClient = new(new Uri("https://xxxxxxxx.communication.azure.com/"), chatTokenCredentials);
ChatThreadClient chatThreadClient = chatClient.GetChatThreadClient(classeVirtualeEntity.ChatThreadId);
await chatThreadClient.AddParticipantAsync(new ChatParticipant(tokenResponse.Value.User));
Expected behavior
await chatThreadClient.AddParticipantAsync(new ChatParticipant(tokenResponse.Value.User));
This line should add the partecipant and do no’t trigger an Exception.
Actual behavior
It won’t go further and triggers an Exception that I catch but it doesn’t specify anything else.
Reproduction Steps
I create the scopes
I create the ACS user id and token with the CommunicationIdentityClient service injected:
private readonly CommunicationIdentityClient _identityClient;
public MyService(CommunicationIdentityClient identityClient){
_identityClient = identityClient;
}
I create the CommunicationTokenCredential with the token from the user
I create the ChatClient with that and the endpoint of my ACS Service from Azure Portal
I retrieve the ChatThreadClient from ChatClient
I launch the method AddParticipantAsync
It triggers an Exception
Service request failed.
Status: 403 (Forbidden)
Content:
{
"CommunicationError": {
"Code": "Forbidden",
"Message": "The initiator doesn't have the permission to perform the requested operation.",
"Details": []
}
}
Headers:
Transfer-Encoding: chunked
MS-CV: ySHzUBvxeUKgw7cNRLTRVg.0
Strict-Transport-Security: REDACTED
api-supported-versions: REDACTED
X-Processing-Time: REDACTED
x-ms-client-request-id: ac3aa147-80cf-466c-9a5f-5fef7f268da1
X-Cache: REDACTED
X-Azure-Ref: REDACTED
Date: Wed, 31 May 2023 12:46:06 GMT
Content-Type: application/json
Environment
No response
Issue Analytics
- State:
- Created 4 months ago
- Comments:19 (8 by maintainers)
Top GitHub Comments
I think this is the parameter and it is valid.
It worked, Thank you very much