8

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.

new name
  • 15,861
  • 19
  • 68
  • 114
  • [Directory API: User Aliases](https://developers.google.com/admin-sdk/directory/v1/guides/manage-user-aliases?hl=en) doesn't access what you want? – JSuar Jan 12 '14 at 14:48
  • @JSuar, looks promising. Let me take a look. – new name Jan 12 '14 at 16:35
  • @JSuar, I'm not sure. That looks like it is specific to a Google Apps domain and would not apply to a regular gmail account. – new name Jan 12 '14 at 16:42
  • What about [Class GmailApp -> getAliases()](https://developers.google.com/apps-script/reference/gmail/gmail-app#getAliases())? – JSuar Jan 12 '14 at 18:38
  • @JSuar, that does what I want to do, but it looks limited to Google Apps Script so I couldn't use it for a user logging in to my web site. Thanks for all the effort to help me out. I suspect that Google doesn't currently support what I want. – new name Jan 12 '14 at 21:58
  • @Kekito, I face the same issue, and I also feel that none of the answers below are helpful for this exact problem. Did you manage to find a solution in the meantime? – dorian May 18 '15 at 12:35
  • @dorian, no I never found a solution. – new name May 18 '15 at 13:50

4 Answers4

5

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

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.

JSuar
  • 21,056
  • 4
  • 39
  • 83
1

It has been a while since the question was asked. You can use the Google People API to get a user's primary email address and aliases. Here's the documentation. The scope you need to use is: https://www.googleapis.com/auth/user.addresses.read

This will return all the email addresses for the user and also tell you which is the primary one.

xcvbn
  • 252
  • 1
  • 9
  • 1
    Hi Siva, could you provide a brief working example of an API call that does this? It wasn't obvious to me from the link you provided. – new name Nov 17 '16 at 18:55
0

If you use OAuth to have your users sign-in with their Google accounts (with or without G+) the user will be prompted (by Google) to select which of their accounts they wish to authorize your application to use: https://developers.google.com/accounts/docs/OAuth2Login

So to directly answer your question, I'm not aware of an API to return that list of users - however you shouldn't need to, Google will take care of this before returning to your application.

If your user is already logged in, and you wish to give them the ability to change the Google account they are using, I believe it is possible to prompt them again to select the account they are interested in (search for select_account on the link above).

aeijdenberg
  • 2,427
  • 1
  • 16
  • 13
  • Thanks, but that isn't what I was looking for. You can have multiple email addresses affiliated with a single gmail account. I would like to get the list of email addresses affiliated with one google account, and this different from a user having multiple google accounts. – new name Jan 06 '14 at 23:02
0

This is possible. However, this has changed since Google announced the deprecation of their Google+ People API, which a lot of folks used to get all the email addresses for a user. The current most voted answer now goes to a 404.

Google Plus People API Replacement

Google has replaced the Google Plus People API /plus/v1/people/me with https://developers.google.com/people/ and you’ll want to use the https://www.googleapis.com/auth/user.emails.read profile scope as discussed here as a replacement. The schema is different, so you'll need to change your mapping as well.

If your app already used the following scopes from the old /plus/v1/people/me your user will not have to re-consent when you switch to the new API:

email
profile
https://www.googleapis.com/auth/plus.login
https://www.googleapis.com/auth/plus.me
https://www.googleapis.com/auth/plus.profile.agerange.read
https://www.googleapis.com/auth/plus.profile.emails.read
https://www.googleapis.com/auth/plus.profile.language.read
Brandon Werner
  • 1,305
  • 10
  • 16