Advertisement
Guest User

ionic

a guest
Apr 20th, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         $scope.login = function() {
  2.             var ref = window.open('https://wespot-arlearn.appspot.com/Login.html?client_id=wespotClientId&redirect_uri=http://localhost:8104/callback&response_type=code&scope=profile+email', '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
  3.             console.log(ref.serialize());
  4.             ref.addEventListener('load', function(event) {
  5.                 if((event.url).startsWith("http://localhost:8104/callback")) {
  6.                     requestToken = (event.url).split("code=")[1];
  7.                     $http({method: "post", url: "https://accounts.google.com/o/oauth2/token", data: "client_id=" + clientId + "&client_secret=" + clientSecret + "&redirect_uri=http://localhost/callback" + "&grant_type=authorization_code" + "&code=" + requestToken })
  8.                         .success(function(data) {
  9.                             accessToken = data.access_token;
  10.                             $location.path("/inquiries");
  11.                         })
  12.                         .error(function(data, status) {
  13.                             alert("ERROR: " + data);
  14.                         });
  15.                     ref.close();
  16.                 }
  17.             });
  18.         };
  19.  
  20.         if (typeof String.prototype.startsWith != 'function') {
  21.             String.prototype.startsWith = function (str){
  22.                 return this.indexOf(str) == 0;
  23.             };
  24.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement