Ich arbeite in Client-Seite angularjs.Ich versuche, Google oauth2 zu implementieren. Ich bekomme accesstoken, aber ich muss id_token bekommen.Google oauth2 get id_token
Ich habe app.js, controller.js und html Teil hinzugefügt.
Ich folgte diesem Tutorial: http://anandsekar.github.io/oauth2-with-angularjs/
app.js:
angular
.module('angularoauthexampleApp', [ ])
.config(function ($routeProvider) {
$routeProvider
.when('/', {
templateUrl: 'views/main.html',
controller: 'MainCtrl'
})
.when('/access_token=:accessToken', {
template: '',
controller: function ($location,$rootScope) {
var hash = $location.path().substr(1);
var splitted = hash.split('&');
var params = {};
for (var i = 0; i < splitted.length; i++) {
var param = splitted[i].split('=');
var key = param[0];
var value = param[1];
params[key] = value;
$rootScope.accesstoken=params;
}
$location.path("/about");
}
})
.otherwise({
redirectTo: '/'
});
});
controller.js
angular.module('angularoauthexampleApp')
.controller('MainCtrl', function ($scope) {
$scope.login=function() {
var client_id="your client_id";
var scope="email";
var redirect_uri="http://localhost:9000";
var response_type="token";
var url="https://accounts.google.com/o/oauth2/auth?scope="+scope+"&client_id="+client_id+"&redirect_uri="+redirect_uri+
"&response_type="+response_type;
window.location.replace(url);
};
});
html:
<button class="btn btn-primary" ng-click="login()">Login</button>
prüfen ich versuchte, aber ich bin immer so: "ya29.CjQLA2yjm5drVlAPKU_aKCEFeeMM_Ikezqw7rOe9y2PzUDUdsJSt5A5m1D_sjpOCcryMSmuj" authuser: "2", expires_in: "3600" hd: "xxx.com" prompt: "none " session_state:" bb554bedabf47c6f54aa07d0c69ba383b9ef23a6..1c93" token_type: "Bearer" – RSKMR
I didn; t die bekommen id_token – RSKMR
Bitte mir helfen, ich viel habe Schwierigkeiten – RSKMR