'AzureCommunicationUserCredential' was not found in '@azure/communication-common'

Prabhakaran 1 Reputation point


I was following the tutorial for Azure communication API.
My code is as follows,

import { CallClient, CallAgent } from "@azure/communication-calling";  
import { AzureCommunicationUserCredential } from '@azure/communication-common';  

let call;  
let callAgent;  

const { CommunicationIdentityClient } = require('@azure/communication-administration');  
const connectionString = 'endpoint=...';         //Pasted valid connection string  

let identityResponse = "";  

// Instantiate the identity client  
const identityClient = new CommunicationIdentityClient(connectionString);  
async function init() {  
 identityResponse = await identityClient.createUser();  

 let tokenResponse = await identityClient.issueToken(identityResponse, ["voip"]);  
 const { token, expiresOn } = tokenResponse;  
    const callClient = new CallClient();  

    const tokenCredential = new AzureCommunicationUserCredential(tokenResponse.token);  

    callAgent = await callClient.createCallAgent(tokenCredential);  
    callButton.disabled = false;  

I have valid connection string as I have Communication service resource in Azure. But when NodeJS compiles the program, it produces the following error

When I proceed to run the program, I receive the following error in browser console.

Uncaught (in promise) TypeError: _azure_communication_common__WEBPACK_IMPORTED_MODULE_1__.AzureCommunicationUserCredential is not a constructor
at init (client.js:26)
init @ client.js:26
async function (async)
init @ client.js:17
./client.js @ client.js:32
webpack_require @ bootstrap:19
0 @ log.js:59
webpack_require @ bootstrap:19
(anonymous) @ bootstrap:83
(anonymous) @ bootstrap:83

Please help me to find the root cause.

Azure Communication Services
Azure Communication Services
An Azure communication platform for deploying applications across devices and platforms.
713 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. brtrach-MSFT 15,356 Reputation points Microsoft Employee

    @Prabhakaran Thank you for your question. We apologize for the error that you have encountered.

    This is a known issue with the current SDK. There is a workaround right now to change AzureCommunicationUserCredential -> AzureCommunicationTokenCredential in both your import and constructor.

    Please note that the documentation is being updated to reflect this workaround for now.

    There is an SDK update in the works that will revert back to the AzureCommunicationUserCredential method and will require you to revert your code. We apologize for the frustration that this may cause but the product group is preparing for GA with these changes.

    Please let us know if you have any further questions or concerns.

    0 comments No comments