Tools icon indicating copy to clipboard operation
Tools copied to clipboard

issue with RTC token on the web

Open klestovVlad opened this issue 1 year ago • 10 comments

hello everyone!

I'm having a problem trying to connect to an Agora video channel.

I use generated token from backend and it works on android but not on web. (generated token from console works well)

on test site https://webdemo.agora.io/basicVoiceCall/index.html throws an error "AgoraRTCError CAN_NOT_GET_GATEWAY_SERVER: invalid token, authorized failed"

here is an example of a token and a channel:

token: 007eJxTYHg6ddKCkLSXkvpvT+fPF9up9OQGs8gq2b1py7Je9q99dXqnAkNiikWqUVqaZWpiarJJWmKaZZJpokmiUYqFsXFiomWi6Yo4hpSGQEYG7olXmBkZGBlYgBjEZwKTzGCSBUyyMxQaJh= channel: pleeels

could you suggest what could be the problem?

klestovVlad avatar Mar 02 '23 08:03 klestovVlad

which uid did you set when you generate the token?

plutoless avatar Mar 07 '23 13:03 plutoless

i set 0 (zero)

klestovVlad avatar Mar 09 '23 07:03 klestovVlad

could you pls share your appid and generate a token which expires after 24 hours, so that i can try it out from my end?

plutoless avatar Mar 13 '23 14:03 plutoless

Yep appId: ad8e2ff9eaec4faf9b5a4a2d833aa9a5 token: 007eJxTYPA2kTHZvcKX99eVtfckdt//lBxUzqWVECt7qs9tVri/6gEFhsQUi1SjtDTL1MTUZJO0xDTLJNNEk0SjFAtj48REy0TT2jyBlIZARgbhZAEmRgZGBhYgBvGZwCQzmGQBk+wMBTmpqak5xYwMBgDI/SIN

klestovVlad avatar Mar 14 '23 12:03 klestovVlad

@klestovVlad which channel are you generating with? btw this token also works on your android?

plutoless avatar Mar 15 '23 04:03 plutoless

@plutoless i genenrating with channel: pleeels and its work well on android

klestovVlad avatar Mar 15 '23 07:03 klestovVlad

@klestovVlad i'm not seeing any success channel join with this channel name in our backend, how do you know that you have successfully joined the channel? btw maybe you can also share the code you used to generate token.

plutoless avatar Mar 17 '23 02:03 plutoless

@plutoless We use PHP library for token generation, code is

$token = RtcTokenBuilder2::buildTokenWithUid($appID, $appCertificate, $channel, 0, RtcTokenBuilder2::ROLE_PUBLISHER, $expireTimeInSeconds, $expireTimeInSeconds);

klestovVlad avatar Mar 24 '23 07:03 klestovVlad

it seems that for the web you need to send the uid from the server along with the token and use it to connect. But this scheme does not work for android. For android it ionly works when uid is set to zero

klestovVlad avatar Mar 27 '23 07:03 klestovVlad

@klestovVlad For android it ionly works when uid is set to zero -> this uid refers to the one you used to generate token or the one you used to join channel?

plutoless avatar Mar 31 '23 02:03 plutoless