+2 votes

Hi,

I am looking to return contacts as per your example at

https://www.limilabs.com/blog/get-google-contacts-with-oauth2

I am looking to use a service account as per your example

https://www.limilabs.com/blog/oauth2-gmail-imap-service-account

Is this not supported.

Many Thanks

by (510 points)
retagged by

1 Answer

+1 vote
 
Best answer

The latest version allows you to specify email address in GoogleApi.GetContacts method:

GoogleApi google = new GoogleApi(accessToken);
XmlDocument document = google.GetContacts(userEmail);

Remember to authorize both scopes (https://www.google.com/m8/feeds/, https://mail.google.com/) at:
https://www.google.com/a/cpanel/[your domain]/ManageOauthClients

AssertionFlowClient provider = new AssertionFlowClient(server, certificate)
{
    ServiceAccountId = serviceAccountEmail,
    Scope = string.Join(" ", new[] {GoogleScope.ImapAndSmtp.Name, GoogeScope.ContactsScope.Name}),
    ServiceAccountUser = userEmail,
};
by (301k points)
selected by
Thanks for this - works perfectly.
...