[英]Google no longer supports authentication requests from the web view in ionin app
1) Added inappbrowser plugins 2) added googleplus plugins 3) installed ngcordova 4) install ng-cordova-oauth 1)添加了inappbrowser插件2)添加了googleplus插件3)安装了ngcordova 4)安装了ng-cordova-oauth
angular.module('starter', ['ionic','ngCordova','ngCordovaOauth']) .run(function($ionicPlatform) { $ionicPlatform.ready(function() { if(window.cordova && window.cordova.plugins.Keyboard) { cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true); cordova.plugins.Keyboard.disableScroll(true); } if(window.StatusBar) { StatusBar.styleDefault(); } }); }) .controller('WelcomeCtrl', function($scope, $state, UserService, $ionicLoading,$cordovaOauth) { $scope.googleSignIn = function() { console.log('In My Method'); $cordovaOauth.google("here i am using my client id", ["https://www.googleapis.com/auth/urlshortener", "https://www.googleapis.com/auth/userinfo.email"]).then(function(result) { console.log(JSON.stringify(result)); }, function(error) { console.log('In Error'); console.log(error); }); }; }) .service('UserService', function() { var setUser = function(user_data) { window.localStorage.starter_google_user = JSON.stringify(user_data); }; var getUser = function(){ return JSON.parse(window.localStorage.starter_google_user || '{}'); }; return { getUser: getUser, setUser: setUser }; });
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width"> <title></title> <link rel="manifest" href="manifest.json"> <!-- un-comment this code to enable service worker <script> if ('serviceWorker' in navigator) { navigator.serviceWorker.register('service-worker.js') .then(() => console.log('service worker installed')) .catch(err => console.log('Error', err)); } </script>--> <link href="lib/ionic/css/ionic.css" rel="stylesheet"> <link href="css/style.css" rel="stylesheet"> <!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above <link href="css/ionic.app.css" rel="stylesheet"> --> <!-- ionic/angularjs js --> <script src="lib/ionic/js/ionic.bundle.js"></script> <script src="js/ng-cordova.js"></script> <script src="js/ng-cordova-oauth.min.js"></script> <!-- cordova script (this will be a 404 during development) --> <script src="cordova.js"></script> <!-- your app's js --> <script src="js/app.js"></script> </head> <body ng-app="starter" ng-controller="WelcomeCtrl"> <ion-pane> <ion-header-bar class="bar-stable"> <h1 class="title">Ionic Blank Starter</h1> </ion-header-bar> <ion-content> <a class="google-sign-in button button-block" ng-click="googleSignIn()">Sign in with Google</a> </ion-content> </ion-pane> </body> </html>
This code is for login by google in ionic app. 此代码供Google在Ionic应用中登录。 but after this, i got a issue "Google no longer supports authentication requests from the web view. More information can be found at https://developers.googleblog.com/2016/08/modernizing-oauth-interactions-in-native-apps.html .'
但是在此之后,我遇到了一个问题“ Google不再支持Web视图中的身份验证请求。有关更多信息, 请访问https://developers.googleblog.com/2016/08/modernizing-oauth-interactions-in-native- apps.html 。”
Please help me to solve this issue 请帮我解决这个问题
Unfortunately, you have chosen to implement a soon-to-be-deprecated authentication mechanism for Google. 不幸的是,您选择了为Google实施即将被弃用的身份验证机制。 Apr. 2017 is what I believe is the deprecation date, after which this method will not work, and it currently does not work for newer clients.
我认为2017年4月是弃用日期,在此日期之后此方法将不起作用,并且当前不适用于新客户。
You will have to implement Google Auth login using the mechanism suggested at that website. 您将必须使用该网站建议的机制来实现Google Auth登录。 Or you can use one of the plugins available, like onymos access.
或者,您可以使用可用的插件之一,例如onymos access。
YES ,Google no longer supports authentication requests from the web view 是 ,Google不再支持来自网络视图的身份验证请求
Just try to make use of Native Oauth Process , 只要尝试利用本机Oauth流程,
Please See the link for better understanding 请参阅链接以更好地了解
https://www.joshmorony.com/implementing-google-plus-sign-in-with-oauth-2-0-in-ionic-2/ https://www.joshmorony.com/implementing-google-plus-sign-in-with-oauth-2-0-in-ionic-2/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.