Tools icon indicating copy to clipboard operation
Tools copied to clipboard

RTM Token samples missing channelName

Open sleman opened this issue 4 years ago • 9 comments

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.

sleman avatar Jun 08 '20 17:06 sleman

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.

plutoless avatar Jun 14 '20 09:06 plutoless

maybe you can try running the sample code in sample folder? does that return you null as well?

plutoless avatar Jun 14 '20 09:06 plutoless

RtmUnauthenticatedError: Error Code 5 - Signature verification failed. I keep getting this error. How do I resolve this?

RalphLincoln avatar Feb 10 '21 09:02 RalphLincoln

@RalphLincoln Did you use the same uid on the token generator and in the client ?

alexanza avatar Feb 10 '21 09:02 alexanza

Yes I did...... @alexanza

RalphLincoln avatar Feb 15 '21 00:02 RalphLincoln

@RalphLincoln sorry for late reply. could you pls help share the token you generated with me.

plutoless avatar Feb 28 '21 09:02 plutoless

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?

RalphLincoln avatar Feb 28 '21 09:02 RalphLincoln

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)

amanvision avatar Sep 16 '21 19:09 amanvision

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();
    }

meyfemi avatar Nov 22 '21 19:11 meyfemi