Inappbrowser ionic 不加载 Oauth
Inappbrowser ionic doesn't load Oauth
我正在处理我的项目,使用 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 最近警告说:
https://developers.googleblog.com/2016/08/modernizing-oauth-interactions-in-native-apps.html
出于安全原因,Google 不再允许使用 inAppBrowser 获取令牌。相反,使用 cordova 插件进行 google 登录,例如 https://github.com/EddyVerbruggen/cordova-plugin-googleplus,它使用 android 本机方式。
作为奖励,您将获得与 Android 设备更好的集成:用户不再需要在首次使用时输入他们的电子邮件和密码。
一些应用程序仍然有效的原因是 Google 被分阶段阻止。在控制台中创建的新身份验证凭据不再有效,但旧的可以。在某些时候 none 会,请参阅上面的第一个 link。
我正在处理我的项目,使用 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 最近警告说: https://developers.googleblog.com/2016/08/modernizing-oauth-interactions-in-native-apps.html
出于安全原因,Google 不再允许使用 inAppBrowser 获取令牌。相反,使用 cordova 插件进行 google 登录,例如 https://github.com/EddyVerbruggen/cordova-plugin-googleplus,它使用 android 本机方式。
作为奖励,您将获得与 Android 设备更好的集成:用户不再需要在首次使用时输入他们的电子邮件和密码。
一些应用程序仍然有效的原因是 Google 被分阶段阻止。在控制台中创建的新身份验证凭据不再有效,但旧的可以。在某些时候 none 会,请参阅上面的第一个 link。