大佬教程收集整理的这篇文章主要介绍了android – 如何使用ClientID和ClientSecret在Phonegap中使用Angularjs登录Google OAuth2,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
如果没有任何正确的答案,这个问题似乎正在蔓延.我希望现在应该解决. Google Angular Guys应该会有所帮助.
How to implement Google Auth in phonegap?
最接近的主题是How to use Google Login API with Cordova/Phonegap,但这不是angularjs的解决方案.
我不得不使用以下代码传输javascript变量值:
var el = document.getElementById('test'); var scopeTest = angular.element(el).scope(); scopeTest.$apply(function(){ scopeTest.user = user; scopeTest.logged_in = true; scopeTest.name = user.name; scopeTest.email = user.email; });
.controller('TESTCtrl',function($scope,$ionicPopup) { $scope.logged_in = false; $scope.getMember = function(id) { console.log(id); }; $scope.test = function(){ $ionicPopup.alert({"title":"Clicked"}); } $scope.c@R_197_10636@google = function(){ googleapi.authorize({ client_id: 'CLIENT_ID',client_secret: 'CLIENT_SECRET',redirect_uri: 'http://localhost',scope: 'https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/userinfo.email' }).done(function(data) { accessToken=data.access_token; // alert(accessToken); // $loginStatus.html('Access Token: ' + data.access_token); console.log(data.access_token); //$ionicPopup.alert({"title":JSON.Stringify(data)}); $scope.getDataProfile(); }); }; $scope.getDataProfile = function(){ var term=null; // alert("getTing user data="+accessToken); $.ajax({ url:'https://www.googleapis.com/oauth2/v1/userinfo?alt=json&access_token='+accessToken,type:'GET',data:term,dataType:'json',error:function(jqXHR,text_status,strError){ },success:function(data) { var item; console.log(JSON.Stringify(data)); // Save the userprofile data in your localStorage. window.localStorage.gmailLogin="true"; window.localStorage.gmailID=data.id; window.localStorage.gmailEmail=data.email; window.localStorage.gmailFirstName=data.given_name; window.localStorage.gmailLastName=data.family_name; window.localStorage.gmailProfilePicture=data.picture; window.localStorage.gmailgender=data.gender; window.localStorage.gmailName=data.name; $scope.email = data.email; $scope.name = data.name; } }); //$scope.disconnectUser(); //This call can be done later. }; $scope.disconnectUser = function() { var revokeUrl = 'https://accounts.google.com/o/oauth2/revoke?token='+accessToken; // Perform an asynchronous GET request. $.ajax({ type: 'GET',url: revokeUrl,async: false,contentType: "application/json",dataType: 'jsonp',success: function(nullResponsE) { // Do something Now that user is disconnected // The response is always undefined. accessToken=null; console.log(JSON.Stringify(nullResponsE)); console.log("-----signed out..!!----"+accessToken); },error: function(E) { // Handle the error // console.log(E); // You Could point users to manually disconnect if unsuccessful // https://plus.google.com/apps } }); }; })
我正在为尝试使用Google OAuth2登录时面临类似问题的新手提供此答案.因此,我无耻地要求UpVotes,因为我也是新来的!
以上是大佬教程为你收集整理的android – 如何使用ClientID和ClientSecret在Phonegap中使用Angularjs登录Google OAuth2全部内容,希望文章能够帮你解决android – 如何使用ClientID和ClientSecret在Phonegap中使用Angularjs登录Google OAuth2所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。