Search code examples
google-apigmailgoogle-oauthgoogle-openidgmail-api

How can I reliably link to a Gmail conversation given a thread ID if the user is logged into multiple accounts?


If you're logged into multiple Gmail accounts, Google changes the URLs to reference which account you're currently using. For example:

https://mail.google.com/mail/u/0/#inbox/138d85da096d2126 for a convo in my primary account vs https://mail.google.com/mail/u/1/#inbox/128cfe99d055805d for a convo in another one of my accounts.

Note that one account has /u/0 in the URL and the other has u/1.

My question is: given that I've used the Gmail REST API to find the ID of a particular thread, how can I reliably link to that thread? Is there any programmatic way to ask Google which accounts the user is logged into, and what sequence (0, 1, 2, ...) each account falls under?


Solution

  • Looks like you can include a query parameter called authUser that specifies the email account you want to link to:

    https://mail.google.com/mail/[email protected]#all/138d85da096d2126