Search code examples
androidgoogle-apigoogle-oauthgoogle-contacts-api

Google contacts using OAuth 2 on Android


I want to list gmail contacts of user using oAuth 2. I am able to get access token and refresh token by following this tutorial http://www.learn2crack.com/2014/01/android-oauth2-webview.html.

Now I want to get contacts list using access token and refresh token.

I am using Oauth 2 play ground and able to get the contacts on play ground. But how to get contacts using access token and refresh token in android code.


Solution

  • I got Solution from this link https://developers.google.com/accounts/docs/OAuth2WebServer.

    After your application obtains an access token, you can use the token to make calls to a Google API on behalf of a given user account or service account. To do this, include the access token in a request to the API by including either an access_token query parameter or an Authorization: Bearer HTTP header. When possible, the HTTP header is preferable, because query strings tend to be visible in server logs.

    My Http Get request is:

    GET https://www.google.com/m8/feeds/contacts/default/full?max-results=1000&alt=json

    headers :

    Authorization: Bearer 1/fFBGRNJru1FQd44AzqT3Zg

    GData-Version: 3.0