Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $scope.login = function() {
- 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');
- console.log(ref.serialize());
- ref.addEventListener('load', function(event) {
- if((event.url).startsWith("http://localhost:8104/callback")) {
- requestToken = (event.url).split("code=")[1];
- $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 })
- .success(function(data) {
- accessToken = data.access_token;
- $location.path("/inquiries");
- })
- .error(function(data, status) {
- alert("ERROR: " + data);
- });
- ref.close();
- }
- });
- };
- if (typeof String.prototype.startsWith != 'function') {
- String.prototype.startsWith = function (str){
- return this.indexOf(str) == 0;
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement