Invalid value for ByteString error when calling gmail send API with base64 encoded < or>

后端 未结 5 1366
南笙
南笙 2021-01-03 22:07

Really stuck on this one and pulling my hair out trying to figure out what to do, searched everywhere and tried everything but still stuck. Any help is much appreciated.

5条回答
  •  情话喂你
    2021-01-03 22:44

    From Google's gmail rest api (sending messages):

    "The entire email message in an RFC 2822 formatted and base64url encoded string. Returned in messages.get and drafts.get responses when the format=RAW parameter is supplied."

    base64url encoding is not the same as base64 encoding.

    in python, the base64 library offers b64encode() and urlsafe_b64encode(). If you don't use urlsafe_b64encode(), you will get that error, not all the time so it may pass a simple unit test, but it will fail soon enough.

提交回复
热议问题