簡體   English   中英

Google不再支持ionin應用程序中來自網絡視圖的身份驗證請求

[英]Google no longer supports authentication requests from the web view in ionin app

1)添加了inappbrowser插件2)添加了googleplus插件3)安裝了ngco​​rdova 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> 

此代碼供Google在Ionic應用中登錄。 但是在此之后,我遇到了一個問題“ Google不再支持Web視圖中的身份驗證請求。有關更多信息, 訪問https://developers.googleblog.com/2016/08/modernizing-oauth-interactions-in-native- apps.html 。”

請幫我解決這個問題

不幸的是,您選擇了為Google實施即將被棄用的身份驗證機制。 我認為2017年4月是棄用日期,在此日期之后此方法將不起作用,並且當前不適用於新客戶。

您將必須使用該網站建議的機制來實現Google Auth登錄。 或者,您可以使用可用的插件之一,例如onymos access。

,Google不再支持來自網絡視圖的身份驗證請求

只要嘗試利用本機Oauth流程,

請參閱鏈接以更好地了解

https://www.joshmorony.com/implementing-google-plus-sign-in-with-oauth-2-0-in-ionic-2/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM