Ask for token when importing document from Google+. Fixes #353

This commit is contained in:
benweet 2014-03-19 22:52:51 +00:00
parent 17f5275c28
commit d445ccfec8

View File

@ -215,7 +215,7 @@ define([
authenticate(task, 'gdrive', accountId); authenticate(task, 'gdrive', accountId);
task.enqueue(); task.enqueue();
}; };
function runWithToken(accountId, functionToRun) { function runWithToken(accountId, functionToRun) {
var currentToken = gapi.auth.getToken(); var currentToken = gapi.auth.getToken();
var authorizationMgr = authorizationMgrMap[accountId]; var authorizationMgr = authorizationMgrMap[accountId];
@ -262,7 +262,7 @@ define([
// if(etag !== undefined) { // if(etag !== undefined) {
// headers["If-Match"] = etag; // headers["If-Match"] = etag;
// } // }
var base64Data = utils.encodeBase64(content); var base64Data = utils.encodeBase64(content);
var multipartRequestBody = [ var multipartRequestBody = [
delimiter, delimiter,
@ -277,7 +277,7 @@ define([
base64Data, base64Data,
close_delim close_delim
].join(""); ].join("");
runWithToken(accountId, function() { runWithToken(accountId, function() {
var request = gapi.client.request({ var request = gapi.client.request({
'path': path, 'path': path,
@ -320,7 +320,7 @@ define([
}); });
task.enqueue(); task.enqueue();
}; };
googleHelper.rename = function(fileId, title, accountId, callback) { googleHelper.rename = function(fileId, title, accountId, callback) {
var result; var result;
var task = new AsyncTask(); var task = new AsyncTask();
@ -424,7 +424,7 @@ define([
'pageToken': nextPageToken 'pageToken': nextPageToken
}); });
} }
request.execute(function(response) { request.execute(function(response) {
if(!response || !response.largestChangeId) { if(!response || !response.largestChangeId) {
// Handle error // Handle error
@ -755,6 +755,10 @@ define([
if(pickerType == 'doc' || pickerType == 'folder') { if(pickerType == 'doc' || pickerType == 'folder') {
authenticate(task, 'gdrive', accountId); authenticate(task, 'gdrive', accountId);
} }
else {
accountId = 'google.picasa0';
authenticate(task, 'picasa', accountId);
}
loadPicker(task); loadPicker(task);
task.onRun(function() { task.onRun(function() {
var authorizationMgr = authorizationMgrMap[accountId]; var authorizationMgr = authorizationMgrMap[accountId];
@ -794,6 +798,7 @@ define([
view.setType('ofuser'); view.setType('ofuser');
pickerBuilder.addView(view); pickerBuilder.addView(view);
pickerBuilder.addView(google.picker.ViewId.PHOTO_UPLOAD); pickerBuilder.addView(google.picker.ViewId.PHOTO_UPLOAD);
authorizationMgr && authorizationMgr.token && pickerBuilder.setOAuthToken(authorizationMgr.token.access_token);
} }
pickerBuilder.setCallback(function(data) { pickerBuilder.setCallback(function(data) {
if(data.action == google.picker.Action.PICKED || data.action == google.picker.Action.CANCEL) { if(data.action == google.picker.Action.PICKED || data.action == google.picker.Action.CANCEL) {
@ -1032,7 +1037,7 @@ define([
}); });
task.enqueue(); task.enqueue();
}; };
// Use by Google's client.js // Use by Google's client.js
window.delayedFunction = undefined; window.delayedFunction = undefined;
window.runDelayedFunction = function() { window.runDelayedFunction = function() {
@ -1040,6 +1045,6 @@ define([
window.delayedFunction(); window.delayedFunction();
} }
}; };
return googleHelper; return googleHelper;
}); });