Sì, è possibile utilizzare l'API di Drive, ma è necessario utilizzare il client JS di Google solo fornire portata, ID client, segreto client e caricare client js e effettuare chiamate API. Ma in origine JavaScript ci deve essere il vostro Chrome Extension id (cromo-extension: // abcdefghijklmnopqrstuvwxyx)
sotto le funzioni può essere utile per voi
// on client load call this function
var handleClientLoadAuto = function() {
gapi.client.setApiKey(apiKey);
window.setTimeout(checkAuthAuto, 1);
}
e
var checkAuthAuto = function() {
gapi.auth.authorize({
client_id: clientId,
scope: 'scope here',
immediate: true
}, handleAuthResultAuto);
}
e se tutto è OK:
var handleAuthResultAuto = function (authResult) {
if (authResult && !authResult.error) {
//do call to drive api using
gapi.client.load('drive', 'v2', function() {
var request = gapi.client.drive.files.list(params);
request.execute(function (resp) {
if (resp && resp.error) {
//call to error callback function
//handleError(resp);
} else {
//ok response
}
});
}
} else {}
}
Ma per utilizzare questo devi essere loggato altrimenti non lo farà t rilevare l'autorizzazione.
fonte
2013-03-01 11:39:51