Tinode token malformed error when decoded by php

16 views
Skip to first unread message

Ons Ta

unread,
Dec 15, 2022, 4:58:27 PM12/15/22
to Tinode General
I can not understand what I am doing wrong.
When I take a token from Tindroid, then base64 decode it with php, in some cases I can not login with GRPC - Tinode returns malformed error.

For example.

<?php

$token = ' 3X3jPTdOIYdz24hkFAABAAEAIAzgCv1K7A/0LKspbEAvK6vjZHPjSYk3IGd eyzbkQ8'; //a token from Tindroid

$token = base64_decode($token);

echo $token;
?>

Echo produces:

Ý}ã=7N!‡sÛˆd à
ýJì ô,«)l@/+«ãdsãI‰7 g^Ë6äC


As you can see, there is a newline. Do tokens contain newlines. As I understand, malformed error appears when a token after decoding contains a newline.

How to resolve this problem? Thanks.

Gene

unread,
Dec 15, 2022, 5:08:33 PM12/15/22
to Tinode General
On Thursday, December 15, 2022 at 1:58:27 PM UTC-8 Ons Ta wrote:
I can not understand what I am doing wrong. 
When I take a token from Tindroid, then base64 decode it with php, in some cases I can not login with GRPC - Tinode returns malformed error.

For example.

<?php

$token = ' 3X3jPTdOIYdz24hkFAABAAEAIAzgCv1K7A/0LKspbEAvK6vjZHPjSYk3IGd eyzbkQ8'; //a token from Tindroid
           ^^ whitespace                                                ^^ whitespace      


It's most likely a problem with URL decoding/encoding. The '+' is converted to space.
Reply all
Reply to author
Forward
0 new messages