Reputation: 648
Is there a way to tie Spreadsheets API in with Drive API? By which I mean, if I have a file ID from Google Drive can I then switch to the Spreadsheets API using the same ID and the same oAuth credentials?
I am using php and there is precious little resources especialy for the spreadsheet api - I'm suprised there's so little around.
Upvotes: 3
Views: 1357
Reputation: 411
Here's the solution I came up with:
https://www.googleapis.com/auth/drive
AND
https://spreadsheets.google.com/feeds
.$tok = json_decode([token string])
$authsub = Zend_Gdata_AuthSub::getHttpClient($tok->access_token);
$spreadsheet_service = new Zend_Gdata_Spreadsheets($authsub);
Now you can use your spreadsheet service as documented in the Zend library. Works great.
Upvotes: 2
Reputation: 9213
You additionally need to grant permission for user for the following scope:
https://spreadsheets.google.com/feeds
The resources IDs are identical on both APIs. My spreadsheet file on Drive, identified with 0AifSjdPVs9MZdE10eXZTVHVneW9aYjJGVFMxV0VYUEE
is accessible on Spreadsheets API with the same ID:
https://spreadsheets.google.com/feeds/spreadsheets/0AifSjdPVs9MZdE10eXZTVHVneW9aYjJGVFMxV0VYUEE
Note: I made the spreadsheet publicly readable, you can try out Spreadsheets API backends with this file.
Upvotes: 3