You are here

How to Implement the Google Contacts API Version 3.0 in C# and ASP.NET with OAuth 2.0

Email is still one of the most powerful tools for pushing content directly to users on demand, which makes it a key component of many marketing strategies. As a part of those strategies, developers of client applications regularly leverage the power of the Google Contacts API to access an existing user’s contacts list that can be used to appeal to new potential users and gain more traffic.
As per other Google Data APIs, this system accepts HTTP requests containing XML-encoded input arguments and returns Atom feeds containing the requested information that can then be parsed in any XML-aware programming language. In this tutorial on Yogi Hosting, followers are shown how to implement the Google Contacts API v3.0 in C# and ASP.NET and using OAuth 2.0 for authentication.
Followers should begin by creating an API Project in Google APP Console and turning on the Contacts API in the left sidebar. Set up the consent screen that users will be shown whenever you request access to their contacts, then create a new Client ID. Don’t forget to enter the Authorized Redirect URI that users are taken to once they have given permission. Finalizing the creation of this Client ID will also create a new Client Secret, both of which should be saved for later steps.
OAuth 2.0 is used to authenticate the user and ask for permission to share their contacts with the app, sending an Authorization Code once permission is granted via a button click event. The author provides the relevant parameters for the HTTP POST request for exchanging this Authorization Code for an Access Token.
This Access Token can then be used to make Google API calls to get the user’s contacts that are returned in JSON format. All relevant URLs to make the calls are provided, as is the application code, and users can also download the full application using the link at the bottom of the page.

Be sure to read the next Authentication article: How and When to Use Various API Authentication Methods

Original Article

Implementing Google Contacts API Version 3.0 & OAuth 2.0 in CSharp and ASP.NET