Search code examples
google-apigoogle-plusgoogle-contacts-api

Google Contacts API — read-only access


I'm trying to access contacts.readonly scope while having Contacts API enabled in my project's APIs in Google Developers Console.

$ export client_id='**********************************************.apps.googleusercontent.com'
$ export scope='https://www.googleapis.com/auth/contacts.readonly'
$ curl -d "client_id=${client_id}&scope=${scope}" https://accounts.google.com/o/oauth2/device/code
{
  "error" : "invalid_scope",
  "error_description" : "Not authorized to request the scopes: [https://www.googleapis.com/auth/contacts.readonly]",
  "error_uri" : "http://code.google.com/apis/accounts/docs/OAuth2.html"
}

When I change the scope to read-write, this works:

$ export scope='https://www.google.com/m8/feeds'
$ curl -d "client_id=${client_id}&scope=${scope}" https://accounts.google.com/o/oauth2/device/code
{
  "device_code" : "*********************************************",
  "user_code" : "********",
  "verification_url" : "https://www.google.com/device",
  "expires_in" : 1800,
  "interval" : 5
}

Adding Google+ API in the Console doesn't help either.


Solution

  • The OAuth2 for Devices flow currently only supports a subset of Google scopes. If you want to have the contacts.readonly scope added to that list please file an enhancement request on the issue tracker.