Tools
Tools copied to clipboard
RTM Token samples missing channelName
When calling the buildToken method with all the required arguments downloaded from: https://github.com/AgoraIO/Tools/blob/master/DynamicKey/AgoraDynamicKey/php/src/RtmTokenBuilder.php
$token is always null
and then the next line fails because $token is null
$token->addPrivilege($Privileges["kRtmLogin"], $privilegeExpireTs);
buildToken calls AccessToken::init without a channelName while the method requires a channeName in the function definition.
The same issue exists in your python3 and javascript samples in the master branch.
Even after fixing this issue, now I am getting an error when calling rtm api join.
RTM:ERROR Error Code 5. Signature verification failed.
umm i tried php version and it's working properly for me. which php version are you using?
bash-3.2$ php RtmTokenBuilderSample.php
Rtm Token: 006970CA35de60c44645bbae8a215061b33IADhrR1vsVX3JqBO951BdxlKa7OVqwT7MGhhp86rpgdXd10HL3sAAAAAEAAdcgAA9DfnXgEA6AOE9OVe
bash-3.2$
it you look into the code you will notice rtm token builder is placing userAccount in init function channelName field. so as long as you provide userAccount, it should not return null.
maybe you can try running the sample code in sample folder? does that return you null as well?
RtmUnauthenticatedError: Error Code 5 - Signature verification failed. I keep getting this error. How do I resolve this?
@RalphLincoln Did you use the same uid on the token generator and in the client ?
Yes I did...... @alexanza
@RalphLincoln sorry for late reply. could you pls help share the token you generated with me.
It's been quite a long time now, I decided to move on without the token. But is the token needed in production. Could it break the application?
Hi there, Sample code works correctly, Following works for me:
Generate your $userAccount or $uid as:
$user = random_int(100000000, 999999999); $user = (string)$user; IMP: make sure you cast user id to string.
Pass this to RtmTokenBuilder::buildToken
Also, pass the same user id to AgoraEduSDK.launch config (userUuid)
I found the issue, in the RtmTokoenBuilder.php class, update buildToken() method with the code snippet below
public static function buildToken($appID, $appCertificate,$channelName, $userAccount, $role, $privilegeExpireTs){
$token = AccessToken::init($appID, $appCertificate, $channelName,$userAccount);
$Privileges = AccessToken::Privileges;
$token->addPrivilege($Privileges["kRtmLogin"], $privilegeExpireTs);
return $token->build();
}