I'm attempting to use the Google Sites API to retrieve a list of all of my domain's sites, not just the sites that the currently authenticated user has read-write/owner access to. As far as I can tell, there is no facility to handle this in the current API.
However, according to the current API reference (https://developers.google.com/google-apps/sites/docs/1.0/reference/) I can use a parameter to include all sites that a user can at least 'view'. This combined with using a domain admin user seems like it would handle my requirements.
Unfortunately, I can't get this to work. I'm using a 2-legged oAuth approach, almost identical to the folllowing example here: http://gdatatips.blogspot.ca/search/label/oauth except that I'm using the sites feed.
I can successfully specify the [email protected] and retrieve a list of sites. But if I add the 'include-all-sites' parameter to my feed url, ie:
https://sites.google.com/feeds/site/mydomain.com/?include-all-sites=true
I receive the following error:
Unknown authorization header Error 401
Is there another way to do this? I can't find any documentation or working examples that use the 'include-all-sites' parameter.
Update:
Here's the header output:
GET /feeds/site/mydomain.com/?include-all-sites=true HTTP/1.1
Host: sites.google.com
Accept: */*
Authorization: OAuth oauth_version="1.0", oauth_nonce="831c013d3d4c9c13b149dfd21e9b48bd", oauth_timestamp="1337274463", oauth_consumer_key="mydomain.com", xoauth_requestor_id="user%mydomain.com", oauth_signature_method="HMAC-SHA1", oauth_signature="%2Bq24MoAQJL4vCcz%2BLD1P1Cy4X48%3D"
Content-Type: application/atom+xml
GData-Version: 1.4
HTTP/1.1 401 Unknown authorization header
WWW-Authenticate: GoogleLogin realm="http://www.google.com/accounts/ClientLogin", service="jotspot"
Content-Type: text/html; charset=UTF-8
Date: Thu, 17 May 2012 17:07:43 GMT
Expires: Thu, 17 May 2012 17:07:43 GMT
Cache-Control: private, max-age=0
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Server: GSE
Transfer-Encoding: chunked
Turns out I had an issue with my implementation of the OAuth Libraries. This is all working as expected now. Below is my working code..
This example requires that you have the Google APIs Client Library for PHP: http://code.google.com/p/google-api-php-client/
The code above uses the below utility functions (from: http://gdatatips.blogspot.ca/search/label/oauth)
I hope this helps anyone else who may need similar functionality!