Using gapi.client.request, I can successfully retrieve from Drive.
However, if I invalidate the access token and try again, I get a 401 as expected, followed by a call to https://accounts.google.com/o/oauth2/auth?scope=&immediate=true&proxy=oauth2relay530384583&redirect_uri=postmessage&origin=http%3A%2F%2Fdev.myapp.co%3A9000&response_type=token&state=780297101%7C0.3257751071&authuser=0
which fails 400 "Missing required parameter: scope"
Looking at the URL, the scope is indeed empty, but why?
At the beginning of the authentication, I'm setting my scopes using an array thus ...
var scopes = [ 'https://www.googleapis.com/auth/drive', 'https://www.googleapis.com/auth/drive.file', 'https://www.googleapis.com/auth/userinfo.email',
'https://www.googleapis.com/auth/userinfo.profile', "https://docs.googleusercontent.com/", "https://docs.google.com/feeds/",
"https://www.googleapis.com/auth/drive.install","https://www.googleapis.com/auth/tasks" ];
The code itself is ...
var request = gapi.client.request({
'path': '/drive/v2/files/'+qObject.id,
'method': 'GET',
'params': {'maxResults': '1'}
});
request.execute(function(resp) {
console.log(resp); // this get works as expected
});
// now invalidate the access token
var token=gapi.auth.getToken();
token.access_token = "foo";
gapi.auth.setToken(token);
request = gapi.client.request({
'path': '/drive/v2/files/'+qObject.id,
'method': 'GET',
'params': {'maxResults': '1'}
});
request.execute(function(resp) {
console.log(resp); // this fails with a 401 as expected, but fails to get a new token
});