Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get all email addresses of user using Google API

For my own gmail account, I have multiple email addresses associated with it. For example, I have an email address from my university that is associated with my gmail, and I can send emails from my gmail as if they are coming from my university email address.

I'm reading up on the Google APIs, and I see that I can get a user's gmail address, but can I also get any other email address that is associated with their gmail account?

When a user logs in to my site, I'd like to present them with a list of the gmail-associated email addresses and let them select the one they would like to use.

EDIT: Thanks everyone for the answers, but I don't think any of them answers the question. I've been playing with Google's OAuth playground. It is strange that I can get lots of very personal information (a list of a user's contacts and even received emails) but I can't get the user's alternative email addresses.

like image 606
gaefan Avatar asked Jan 01 '14 16:01

gaefan


1 Answers

Your description is a little vague. Are you talking about send-as alias accounts or alternate email accounts?

Send-as Alias

Either way, you can interact with the send-as accounts here: Manage Send-as Alias

Alternate Emails via Admin SDK

  • As for alternate email accounts, they can be accessed via:
    • Admin SDK: https://developers.google.com/admin-sdk/directory/v1/guides/manage-user-aliases?hl=en
    • Google Apps Script: https://developers.google.com/apps-script/reference/gmail/gmail-app#getAliases()
  • Additional info here on how the accounts work.
    • Email addresses associated with your account
    • Alternate email addresses and other Google products
    • Connect other email accounts to your Google Account

Federated Login

Also, I'm not exactly sure how you are trying to incorporate this functionality into your site but another area I recommend checking out is Federated Login for Google Account Users. This might also provide you with the functionality you seek.

Using federated login (also known as federated identity), your website or application can allow visitors to sign in using their Google user accounts. Federated login frees users from having to set up separate login accounts for different websites, and frees you from the task of implementing login authentication measures.

like image 182
JSuar Avatar answered Sep 22 '22 13:09

JSuar