Help with decoding token.

  • {"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkZXZpY2VOYW1lIjoibm9uZSIsImRldmljZVR5cGUiOiJkZXNrdG9wIiwidG9rZW5UeXBlIjoiYXV0aGVudGljYXRpb24iLCJ1dWlkIjoiMDkyODI5NTctMWM5MS00ZWI0LWFkNjktZTcyOWI1MGRmNDcxIiwiaWF0IjoxNTY3MzQxNjI3LCJleHAiOjE1NjczNDI1Mjd9.gFZyozd6hIg4HTRNxHHKI9AATcLbLuxAS6o9nXiOuvU"

    I need to do it in OB, any help is appreciated...

  • Admin

    It's simple base 64 but first you need to remove the dots I guess.
    So 2 blocks, one that replaces a dot with nothing and then one that does base64 decode.

  • PARSE "<SOURCE>" JSON "token" -> VAR "TOKEN"

    FUNCTION Replace "." "" "<TOKEN>" -> VAR "TK"

    FUNCTION Base64Decode "<TK>" -> VAR "TKENC"

    @Ruri It's not working

  • Admin

    Ah yes, I remember this. Basically the base64 string needs to have a number of characters that is a multiple of 4 (if i remember correctly). Try adding some characters at the end and see if you can get it to convert correctly, then you can always cut the string and remove the extra characters later. For example try to add one or two = characters at the end!

  • Sorry buddy it's not working

  • Actually I have you the solution some hours ago on discord...
    but well
    It's a JWT token. - it is
    header.payload.signature - each of it is base64 encoded.

    So to decode the payload parse it and base64 decode it.
    If you have the token in a var named TOK, then do;

    PARSE "<TOK>" LR "." "." -> VAR "PAYLOAD" 
    FUNCTION Base64Decode "<PAYLOAD>" 

    In your case:

  • Many thanks bro.

Log in to reply