【发布时间】:2016-11-02 11:43:24
【问题描述】:
我正在使用 inappbrowser ionic 查看我的 webapp 的项目。我按照说明 (http://sourcefreeze.com/cordova-inappbrowser-plugin-example-using-ionic-framework/) 并在我的设备(iphone 6s、ios 10.1.1)上运行该应用程序。我的网络应用使用 google api,这里是服务
function GoogleDriveAuthentication($rootScope){
this.authenticate = function(){
gapi.load('client:auth2',authorize);
}
function authorize(){
gapi.client.setApiKey($rootScope.API_KEY);
gapi.auth2.init({
client_id: $rootScope.CLIENT_ID,
scope: $rootScope.SCOPES
}).then(function(authResult){
var auth2 = gapi.auth2.getAuthInstance();
var user = auth2.currentUser.get();
if (user.isSignedIn()) {
afterSignInSuccess();
} else {
auth2.signIn().then(afterSignInSuccess,afterSignInFailed);
}
});
}
function afterSignInFailed(respond){
console.log(respond);
}
function afterSignInSuccess(respond){
console.log('authenticated successfully');
var auth2 = gapi.auth2.getAuthInstance();
var user = auth2.currentUser.get();
var authResponse = user.getAuthResponse();
$rootScope.accessToken = user.getAuthResponse().access_token;
$rootScope.authenticated = true;
gapi.client.load('drive', 'v3',function(){
$rootScope.$broadcast('authenticated');
});
}
}
这是我的 app.js 的一部分
app.run(function($rootScope,$location,$route, GoogleDriveAuthentication,DTOptionsBuilder){
$rootScope.$on('$routeChangeSuccess', function(){
document.title = "SuperProject - " + $route.current.title;
$('#superSearch').typeahead('val', '');
if ($location.path() != "/register" && $location.path() != "/forgot"){
if (!$rootScope.loggedin){
console.log($rootScope.loggedin);
$location.path("/login");
}
else if (!$rootScope.authenticated){
console.log('authenticate');
GooghleDriveAuthentication.authenticate();
}
}
if ($location.path != '/home') {
$('#superSearch').blur();
}
})
And when I run it in Inappbrowser, it's stuck like this
我的科尔多瓦插件:
cordova-plugin-console 1.0.4 "Console"
cordova-plugin-device 1.1.3 "Device"
cordova-plugin-inappbrowser 1.5.0 "InAppBrowser"
cordova-plugin-splashscreen 4.0.0 "Splashscreen"
cordova-plugin-statusbar 2.2.0 "StatusBar"
cordova-plugin-whitelist 1.3.0 "Whitelist"
ionic-plugin-keyboard 2.2.1 "Keyboard"
在这种情况下,我可能会遇到我使用的 oauth2 v3 会在 Inappbrowser 中产生一些问题,我不确定。 知道我的应用有什么问题吗?任何帮助将不胜感激:)
【问题讨论】:
-
google 不再允许来自 inappbrowser 的 oauth
-
有任何链接可以证明这一点吗,伙计?
-
顺便说一句,我认为这是一个完全有效的问题。我相信你是第一个在这里发布它的人,因为新的凭据从 11 月起被阻止。 1 2016 年。不知道为什么它被标记为离题。
标签: cordova ionic-framework google-drive-api google-oauth inappbrowser