How to decode base64 url in python?

前端 未结 9 1374
一个人的身影
一个人的身影 2020-12-28 15:24

For Facebook fbml Apps Facebook is sending in a signed_request parameter explained here:

http://developers.facebook.com/docs/authentication/canvas

They have

9条回答
  •  孤城傲影
    2020-12-28 15:50

    This is the right solution. In python there is base64.b64encode but that only base64 encodes and its is different from base64 url encoding. Here is the right set to of steps to convert form base64encoded to base64urlencoded string:
    1. From the resultant string, replace "/" with "_" and "+" with "-"
    2. Strip the trailing "==".

    Et voila! That will make it a valid string for base64 url decoding. Btw, that link in @dae.eklen 's answer above is broken now.

提交回复
热议问题