Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting UID that you get for gmail IMAP using new REST API

Is it possible to get gmail UID that you get while using IMAP api by using new REST API. This would allow to keep some part of my IMAP code as it is and slowly migrate towards the new REST API.

like image 417
Mahesh Avatar asked Jun 27 '14 22:06

Mahesh


2 Answers

Folder UIDs are IMAP protocol specific (and expensive to compute+maintain) so API server doesn't have those. However the X-GM-MSGID and X-GM-THRID Gmail IMAP extensions are indeed the same values the web UI and API use, just in decimal format not hex encoded and you can rely on them being the same according to docs:

"The message ID is a 64-bit unsigned integer and is the decimal equivalent for the ID hex string used in the web interface and the Gmail API."

from: https://developers.google.com/gmail/imap_extensions#access_to_the_gmail_unique_message_id_x-gm-msgid

(Just need to trivially convert between decimal and hex string.)

like image 91
Eric D Avatar answered Sep 22 '22 16:09

Eric D


"Alternatively, it would also work if I can get the ID required for REST API via IMAP api."

Checkout the IMAP extensions for X-GM-MSGID and X-GM-THRID from the following link:

https://developers.google.com/gmail/imap_extensions?hl=ja

They are identical to the message ID and thread ID you get respectively from Gmail API.

I don't believe there is a way to get UID from the REST API since there is no concept of folder in this API. The closest thing is "label" but that's not completely 1-to-1 mapping as far as I can tell.

like image 23
yuklai Avatar answered Sep 21 '22 16:09

yuklai