I am using a PHP server to generate token. When I initialize the chat client with the token generated, I am getting this error.
POST https://ems.us1.twilio.com/v1/token 401 (Unauthorized)
{"message":"The authorization with Token failed","code":2016,"user_error":false,"params":{"description":"Could not authenticate fpa token"}}
EMS E: Error: The authorization with Token failed
Javascript (v2.1) initilization code:
Twilio.Chat.Client.create(token).then(client => {
chatClient = client;
chatClient.getChannelByUniqueName(channelName)
.then(function(chosenChannel) {
myChannel=chosenChannel;
PHP Server code:
$token = new AccessToken( $accountid, $apikey, $apisecret 3600,
$identity);
$chatGrant = new ChatGrant();
$chatGrant->setServiceSid($configs[1]);
$chatGrant->setEndpointId($endpointId);
$token->addGrant($chatGrant);
return $token->toJWT();
Any help?