Insufficient permission while accessing community activities

804 views
Skip to first unread message

Franklin Weng

unread,
Aug 23, 2013, 8:14:16 AM8/23/13
to google-api...@googlegroups.com
Hi forum,

I got problem while trying to get activities from a certain community.

I registered google api console, and wrote a test problem like the following:

<?php
require_once "google-api-php-client/src/Google_Client.php";
require_once "google-api-php-client/src/contrib/Google_PlusService.php";

const SERVICE_ACCOUNT_NAME = 'xxxxxx...@developer.gserviceaccount.com';
const KEY_FILE = '/path/to/my/privatekey/file/privatekey.p12';   // you can bet I didn't really use a file name like this

$client = new Google_Client();
$key = file_get_contents(KEY_FILE);
$client->setClientId(CLIENT_ID);
$client->setAssertionCredentials(new Google_AssertionCredentials(
        SERVICE_ACCOUNT_NAME,
        $key)
);

$plus = new Google_PlusService($client);
$optParams = array('maxResults' => 100);
$activities = $plus->activities->listActivities('COMMUNITY_ID', 'public', $optParams);



When running to the last line, php caught an exception which showed in my apache log:

[Fri Aug 23 20:01:34 2013] [error] [client my_ip] PHP Fatal error:  Uncaught exception 'Google_ServiceException' with message 'Error calling GET https://www.googleapis.com/plus/v1/people/COMMUNITY_ID/activities/public?maxResults=100: (403) Insufficient Permission' in /path/to/my/google-api-php-client/src/io/Google_REST.php:66\nStack trace:\n#0  
[deleted]


This community is public.
I enabled "Google Admin SDK", "Google+ API", "Google+ Hangouts API", and "Prediction API" in the google api console settings.

Could anyone please tell me what else should I do to get the community activities list?


Thanks,
Franklin

Ian Barber

unread,
Aug 23, 2013, 9:02:48 AM8/23/13
to google-api...@googlegroups.com
Communities activities aren't available in the API, hence the error. 

Ian


--
You received this message because you are subscribed to the Google Groups "google-api-php-client" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-api-php-c...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Franklin Weng

unread,
Aug 23, 2013, 10:04:25 AM8/23/13
to google-api...@googlegroups.com
Hi,

Thanks for answering.  But if I change the listActivities from my community id to 'me', or my own id when examining my own activities, I still got the same error.

Or, I just called

$me = $plus->people->get('me');

I still get the same error.

How to get plus data when using service accounts?  What does this 'me' mean when using this way for authentication?  Or, how could I check if my authentication was successful or not?


Thanks,
Franklin



2013/8/23 Ian Barber <ianb...@google.com>

Ian Barber

unread,
Aug 27, 2013, 10:49:40 AM8/27/13
to google-api...@googlegroups.com
Ah right, if using the service account you'd need to have the access delegated to it from a user for me to work - then you could specify with the "sub" parameter. It might be easier to put the Google user ID in rather than "me". If you're getting it even for IDs though, make sure 1) you have the Google+ API enabled on the project 2) You have configured the Google+ scopes for the service account if using an Apps account and hoping to delegate authority.

Ian

Franklin Weng

unread,
Aug 27, 2013, 11:34:58 AM8/27/13
to google-api...@googlegroups.com
Hi,

Here I share the code which I succeeded to get activities using this way.

$client = new Google_Client();
$key = file_get_contents(KEY_FILE);
$client->setClientId(CLIENT_ID);
$client->setAssertionCredentials(new Google_AssertionCredentials(
    SERVICE_ACCOUNT_NAME,
    $key)
);

$plus = new Google_PlusService($client);
$optParams = array('maxResults' => 10);

$activities = $plus->activities->listActivities(MY_USER_ID, 'public', $optParams);



One thing that bothered me was the credential URL (auth/plus.login).  I googled a lot and tried a lot to get it work.  There seems no documents describing the URI for authentication or any other services...

Thanks for your reply!


Franklin



2013/8/27 Ian Barber <ianb...@google.com>
Reply all
Reply to author
Forward
0 new messages