Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Contacts API with Google JavaScript Client Lib

I am trying to work with the Google Contacts API v3.

Because of the OAuth2 authentication and authorization I'm started with the Google APIs Client Library for JavaScript. I have no problems with that part of the API access.

But after doing the auth part I don't know what to do next. Can I use the google-api-javascript-client for the Google Contacts API v3? In the list of the supported Google APIs by the javascript-client the contacts API does not appear. But I have full access with the OAuth 2.0 Playground tool.

I am really confused which client is working best with the latest Google Contacts API. What is about the gdata-javascript-client?

like image 815
einsA Avatar asked Dec 31 '12 17:12

einsA


People also ask

How do I access my Google Contacts API?

To access personal contacts: https://www.googleapis.com/auth/contacts. To access directory information: https://www.googleapis.com/auth/directory.readonly. Note: The Domain Shared Contacts API is not affected by these changes.

What is an API client library?

Let's start with the basics: “what is a client library?” In short, a client library is a collection of code specific to one programming language that makes it easier to use an API. See, almost all web APIs communicate by means of HTTP, and pretty much every programming language supports HTTP.

What is gapi in JavaScript?

GAPI is Google's client library for browser-side JavaScript. It's used in Google Sign-in, Google Drive, and thousands of internal and external web pages for easily connecting with Google APIs.

What is Google API client?

Figure 1: An illustration showing how the Google API Client provides an interface for connecting and making calls to any of the available Google Play services such as Google Play Games and Google Drive. To get started, you must first install the Google Play services library (revision 15 or higher) for your Android SDK.


2 Answers

To use the v3 contacts api with the authentication token provided by gapi (Google JS client lib) this one is helpful, using alt=&json

$.getJSON('https://www.google.com/m8/feeds/contacts/default/full/?access_token=' + 
             authResult.access_token + "&alt=json&callback=?", function(result){
      console.log(JSON.stringify(result));
});
like image 52
ganoro Avatar answered Sep 19 '22 09:09

ganoro


I know it's an old question but this question shows up when looking on how to read the contacts information from a Google account.

If you only need to access the contact to import it or show the email, phone numbers, or other information and you don't need to modify it, you can use the People API (https://developers.google.com/people/). For javascript you can check the samples tab.

I created a gist, which is almost the sample from Google but adding the requestField parameters.

https://gist.github.com/ddbb1977/7a4b408ed17c7249252a

like image 43
Danny Boyd Avatar answered Sep 20 '22 09:09

Danny Boyd