I am using Users.messages.get endpoint to get a gmail response which is in this format as per documentation.
What is the proper way to decode/decrypt the message body from above response?
In my case for example, the "parts" array field in response looks like this:
[
{
"partId": "0.0",
"mimeType": "text/plain",
"filename": "",
"headers": [
{
"name": "Content-Type",
"value": "text/plain; charset=\"UTF-8\"; format=flowed; delsp=yes"
},
{
"name": "Content-Transfer-Encoding",
"value": "base64"
}
],
"body": {
"size": 1628,
"data": "R29vZ2xlIGxvZ28NCg0KSGVsbG8gQXBwcyBTY3JpcHQgdXNlciwNCg0KVGhpcyBub3RpZmljYXRpb24gaXMgdG8gYWxlcnQgeW91IG9mIGFuIHVwZGF0ZSB0byBvbmUgb3IgbW9yZSBvZiB5b3VyIEFwcHMgIA0KU2NyaXB0IHByb2plY3RzIHRoYXQgYXJlIGF0dGFjaGVkIHRvIERvY3MsIFNoZWV0cywgYW5kIEZvcm1zIGRvY3VtZW50cyB3aXRoICANCnNjcmlwdCBzaGFyaW5nIHNldHRpbmdzIHRoYXQgZGlmZmVyIGZyb20gdGhvc2Ugb2YgdGhlIGRvY3VtZW50Lg0KDQpTdGFydGluZyBvbiBvciBhZnRlciBKdWx5IDZ0aCwgMjAxNywgdGhvc2Ugc2NyaXB0IHNoYXJpbmcgc2V0dGluZ3Mgd2lsbCBiZSAgDQp1cGRhdGVkIHRvIG1hdGNoIHRob3NlIG9mIHRoZSBkb2N1bWVudHMgdG8gd2hpY2ggdGhleSdyZSBhdHRhY2hlZC4NCg0KVGhlIHNoYXJpbmcgc2V0dGluZ3MgdXBkYXRlIHNpbXBsaWZpZXMgc2hhcmluZyBzZXR0aW5ncyBmb3IgZG9jdW1lbnRzIHdpdGggIA0KYXR0YWNoZWQgQXBwcyBTY3JpcHQgcHJvamVjdHMgYnkgdHJlYXRpbmcgdGhlbSBsaWtlIGEgc2luZ2xlIGRvY3VtZW50Lg0KDQpBcyBhIHJlc3VsdCBvZiB0aGUgc2hhcmluZyBzZXR0aW5ncyB1cGRhdGUsIGFuZCBhY2NvcmRpbm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IERyaXZlLCBjbGljayBTaGFyZS4NCg0KU2luY2VyZWx5LA0KDQpUaGUgQXBwcyBTY3JpcHQgVGVhbQ0KDQoNCsKpIDIwMTcgR29vZ2xlIEluYy4gMTYwMCBBbXBoaXRoZWF0cmUgUGFya3dheSwgTW91bnRhaW4gVmlldywgQ0EgOTQwNDMNCg0KWW91IGhhdmUgcmVjZWl2ZWQgdGhpcyB1cGRhdGUgYXMgYSBHIFN1aXRlIHNlcnZpY2UgYW5ub3VuY2VtZW50Lg0KDQo="
}
},
{
"partId": "0.1",
"mimeType": "text/html",
"filename": "",
"headers": [
{
"name": "Content-Type",
"value": "text/html; charset=\"UTF-8\""
},
{
"name": "Content-Transfer-Encoding",
"value": "quoted-printable"
}
],
"body": {
"size": 3112,
"data": "PCEtLSBUaGlzIGNvbnRhaW5zIENTUyBpbmZvLCBzdGFydHMgdGhlIGJvZHksIGFuZCBpbnNlcnRzIHRoZSBHb29nbGUgbG9nbyBoZWFkZXIgLS0-DQo8c3BhbiBzdHlsZT0iZm9udC1mYW1pbHk6IFJvYm90bywgQXJpYWwsIHNhbnMtc2VyaWY7IGZvbnQtc2l6ZTogMTRweDsgY29sb3I6ICMwMDAwMDA7Ij4gPC9zcGFuPg0KPGRpdiBzdHlsZT0icGFkZGluZy10b3A6IDIycHg7IHBhZGRpbmctYm90dG9tOiA4cHg7IGJvcmRlci1ib3R0b20tc3R5bGU6IHNvbGlkOyBib3JkZXItYm90dG9tLWNvbG9yOiAjZGNkY2RjOyBib3JkZXItYm90dG9tLXdpZHRoOiAxcHgiIHdpZHRoPSIxMDAlIj48c3BhbiBzdHlsZT0iZm9udC1mYW1pbHk6IFJvYm90bywgQXJpYWwsIHNhbnMtc2VyaWY7IGZvbnQtc2l6ZTogMTRweDsgY29sb3I6ICMwMDAwMDA7Ij48aW1nIGFsdD0iR29vZ2xlIGxvZ28iIGJvcmRlcj0iMCIgc3JjPSJodHRwOi8vd3d3LmdzdGF0aWMuY29tL2ltYWdlcy9icmFu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0aGVhdHJlIFBhcmt3YXksIE1vdW50YWluIFZpZXcsIENBIDk0MDQzPC9wPg0KDQogIDxwPjxpPllvdSBoYXZlIHJlY2VpdmVkIHRoaXMgdXBkYXRlIGFzIGEgRyBTdWl0ZSBzZXJ2aWNlIGFubm91bmNlbWVudC48L2k-PC9wPg0KPC9kaXY-DQo8aW1nIGhlaWdodD0iMSIgd2lkdGg9IjMiIHNyYz0iaHR0cHM6Ly93d3cuZ29vZ2xlLmNvbS9hcHBzZXJ2ZS9ta3QvaW1nL2xUUERhTG1XbHg1blNpbTF6OWp3RG1vTVYzSjRvMVZfcDhjPS5naWYiPg=="
}
}
]
And in above, the body of second element(partId 0.0 with mimeType text/html) looks like this:
"body": {
"size": 3112,
"data": "PCEtLSBUaGlzIGN...<trimmed for succintness>..cDhjPS5naWYiPg=="
}
So how do I decode this data ?. The headers are as follow for above part(partId 0.1)
"headers": [
{
"name": "Content-Type",
"value": "text/html; charset=\"UTF-8\""
},
{
"name": "Content-Transfer-Encoding",
"value": "quoted-printable"
}
]
So the content-transfer-encoding is "quote-printable"
Same encrypted/encoded result is what I get when I fetch other email messages. Not sure how do I decode the data from the body(neither could I find anywhere in the documentation about it).