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.

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: jab@ecil.co.in
    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 *

Try GMass today

It only takes 30 seconds to install it!

Install Now GMass requires Chrome
Share This