<img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=1822615684631785&amp;ev=PageView&amp;noscript=1"/>

How to get a Google user’s email address after the Google+ API shutdown

If you’re a developer using any part of Google’s API, you’ve likely received notices informing you that come March 7, 2019, the Google+ API will be shut down. There’s been some confusion in Google’s notices that makes it unclear exactly what will still be available after the shutdown, so in light of this confusion, I’ll show you what we at GMass have done to address the issue, and how we’ll use Google’s OAuth2 mechanism to still create accounts and retrieve a user’s email address after a successful OAuth flow.

What’s the confusing part?

In Google’s earlier notices, anyone that had made a call to people.plus.get received a notice that looked like:

A few days later though, Google clarified that only projects that directly use the scope plus.me would be affected, in this notice:

This notice is still confusing because although it says that only projects that call the plus.me scope directly are affected, it goes onto say that a project making “any Google+ API calls” should be updated.

Take GMass for example. GMass doesn’t request the plus.me scope directly, but DOES make a call to a Google+ API method.

How GMass is addressing the issue

This is the C# code where we make a call to the Google+ API method people.get:

UserCredential credential = new UserCredential(flow, "me", token);
var plusService = new PlusService(new BaseClientService.Initializer
{
                        HttpClientInitializer = credential,
                        ApplicationName = "Gmass"
});
var person = await plusService.People.Get("me").ExecuteAsync();
string emailAddress = person.Emails.First().Value;

So is GMass affected? I’m not sure. In this Stack Overflow article, the respondent mentions that calls to people.get method are likely to work for years to come, but even he’s not certain. To be safe, we’ve decided to request the user’s email address from the Gmail API rather than the Google+ API. In C#, that looks like:

UserCredential credential = new UserCredential(flow, "me", token);
GmailService service = new GmailService(new BaseClientService.Initializer
{
                        HttpClientInitializer = credential,
                        ApplicationName = "Gmass"
});
string emailAddress = service.Users.GetProfile("me").Execute().EmailAddress;

So there you have it. We are now retrieving the user’s email address using the getProfile method which is part of the Gmail API. We are able to do this because one of the scopes that GMass requests is the https://mail.google.com API scope. If your project is not a Gmail extension, you likely are not requesting this scope, and may need to find another method to retrieve the user’s email address.

See why GMass has 300k+ users and 7,500+ 5-star reviews


Email marketing. Cold email. Mail merge. Avoid the spam folder. Easy to learn and use. All inside Gmail.


TRY GMASS FOR FREE

Download Chrome extension - 30 second install!
No credit card required
Love what you're reading? Get the latest email strategy and tips & stay in touch.
   


2 Comments
  1. For each recipient to whom we have sent a mail. A error message is displayed as shown below.
    Kindly clarify How to overcome this problem mentioned below.

    Individual recipient errors (1):

    Some of your errors are Gmail server errors. Your campaign will automatically re-send to these affected email addresses.

    Email Address: [email protected]
    Error: Google.Apis.Requests.RequestError
    Backend Error [500]
    Errors [
    Message[Backend Error] Location[ – ] Reason[backendError] Domain[global]
    ]

    1. Hi Shakti,

      This is a temporary glitch and GMass will retry to send to that address. There is no needed further action from your end.

Leave a Reply

Your email address will not be published. Required fields are marked *

Find out why GMass is the most popular Gmail mail merge tool in the world

Easy to learn. Easy to use. Packed with time saving, email enhancing features.

Try GMass for free Then check out the quickstart guide to send your first mail merge email in minutes!

GMass

Share This