controller("OauthExample", function($scope, $cordovaOauth, $http) {
$scope.googleLogin = function() {
$cordovaOauth.google("YOUR CLIENTID", ["https://www.googleapis.com/auth/userinfo.email", "https://www.googleapis.com/auth/userinfo.profile"]).then(function(result) {
window.localStorage.setItem("access_token", result.access_token);
$scope.token=JSON.stringify(result);
}, function(error) {
console.log(error);
});
}
$scope.getProfileInfo = function() {
console.log(window.localStorage.getItem('access_token'));
$http.defaults.headers.common.Authorization = "Bearer " + window.localStorage.getItem("access_token");
$http.get("https://www.googleapis.com/oauth2/v1/userinfo?alt=json")
.success(function(data) {
console.log(data);
console.log(data.email);
})
.error(function(error) {
console.log(error);
});
}
});
15 Aralık 2015 Salı
Ionic Framework Google Plus + Api Fonksiyonu
Kaydol:
Kayıt Yorumları (Atom)
Hiç yorum yok:
Yorum Gönder