OpenVidu token is not valid

Hello there!
On android client, based on your demo I can’t auth at room. Server said: Token not valid. But token has generated by server and server have this token at his token list. On another clients we have no problems with tokens.
Here part of my android logs:

2020-05-27 10:26:49.284 24841-29189/io.openvidu.openvidu_android D/SessionActivity: responseString2: {"token":{"id":"wss:\/\/radius-lab.ru?sessionId=1&token=tok_XpyvunnB0zPwoiVb&role=PUBLISHER&version=2.13.0&coturnIp=89.22.182.14&turnUsername=IM2JCL&turnCredential=gbrs1a","session":"1","role":"PUBLISHER","data":"","token":"wss:\/\/radius-lab.ru?sessionId=1&token=tok_XpyvunnB0zPwoiVb&role=PUBLISHER&version=2.13.0&coturnIp=89.22.182.14&turnUsername=IM2JCL&turnCredential=gbrs1a"}}
2020-05-27 10:26:49.618 24841-29238/io.openvidu.openvidu_android I/CustomWebSocketListener: Text Message {"id":0,"error":{"code":401,"message":"Unable to join session 1. Token {\"id\":\"wss:\\/\\/radius-lab.ru?sessionId=1&token=tok_XpyvunnB0zPwoiVb&role=PUBLISHER&version=2.13.0&coturnIp=89.22.182.14&turnUsername=IM2JCL&turnCredential=gbrs1a\",\"session\":\"1\",\"role\":\"PUBLISHER\",\"data\":\"\",\"token\":\"wss:\\/\\/radius-lab.ru?sessionId=1&token=tok_XpyvunnB0zPwoiVb&role=PUBLISHER&version=2.13.0&coturnIp=89.22.182.14&turnUsername=IM2JCL&turnCredential=gbrs1a\"}is not valid. Code: 401"},"jsonrpc":"2.0"}
2020-05-27 10:26:49.619 24841-29238/io.openvidu.openvidu_android E/CustomWebSocketListener: No params {"id":0,"error":{"code":401,"message":"Unable to join session 1. Token {\"id\":\"wss:\\\/\\\/radius-lab.ru?sessionId=1&token=tok_XpyvunnB0zPwoiVb&role=PUBLISHER&version=2.13.0&coturnIp=89.22.182.14&turnUsername=IM2JCL&turnCredential=gbrs1a\",\"session\":\"1\",\"role\":\"PUBLISHER\",\"data\":\"\",\"token\":\"wss:\\\/\\\/radius-lab.ru?sessionId=1&token=tok_XpyvunnB0zPwoiVb&role=PUBLISHER&version=2.13.0&coturnIp=89.22.182.14&turnUsername=IM2JCL&turnCredential=gbrs1a\"}is not valid. Code: 401"},"jsonrpc":"2.0"}

Are you following tutorial step by step? Do you have a proper certificate or a selfsigned one?

Can you share with us OpenVidu logs?

Hi @v12ten,

As I can see in your error,

Token

{"id":"wss:\/\/radius-lab.ru?sessionId=1&token=tok_XpyvunnB0zPwoiVb&role=PUBLISHER&version=2.13.0&coturnIp=89.22.182.14&turnUsername=IM2JCL&turnCredential=gbrs1a","session":"1","role":"PUBLISHER","data":"","token":"wss:\/\/radius-lab.ru?sessionId=1&token=tok_XpyvunnB0zPwoiVb&role=PUBLISHER&version=2.13.0&coturnIp=89.22.182.14&turnUsername=IM2JCL&turnCredential=gbrs1a"}

is not valid.

You’re assuming that the entire object response is a token and this is not correct, you must to access to the token property of the response Object. The correct way to send the token to the session is responseObject.token

Regards

1 Like

Many thanks, Carlos!
It’s really helpful! But early my code with a “bad token” worked. Has smth changed in your github? Cuz I pulled it when I saw this error