【发布时间】:2016-04-28 00:49:01
【问题描述】:
我正在使用 Cordova 开发一个应用程序,并希望将文件保存在 Googe Drive 中。
我已成功使用 cordova-plugin-googleplus (https://github.com/EddyVerbruggen/cordova-plugin-googleplus) 登录 Google。但是我无法让插件返回给我 accessToken 或 idToken,因此我可以使用 Google javascript API。
window.plugins.googleplus.login(
{
'scopes': 'https://www.googleapis.com/auth/drive.file profile',
'offline': true,
'webApiKey': ‘CODE’
},
function (obj) {
$scope.$apply(function() {
$scope.srcImage = obj.imageUrl;
$scope.NomeGoogle = obj.displayName;
});
},
function (msg) {
alert('Erro');
alert('error: ' + msg);
}
);
我尝试使用下面的代码,但返回以下错误:
“未捕获的 gapi.auth2.ExternallyVisibleError: cookiePolicy 无效”
gapi.load('auth2', function() {
gapi.auth2.init({
client_id: 'REVERSED_CLIENTID',
}).then(function(){
auth2 = gapi.auth2.getAuthInstance();
console.log(auth2.isSignedIn.get()); //now this always returns correctly
});
});
【问题讨论】:
标签: javascript cordova google-drive-api phonegap-plugins google-signin