Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.success removed in Angular 1.6 - breaks oauth-ng #149

Open
jwmapana opened this issue Feb 28, 2017 · 7 comments
Open

.success removed in Angular 1.6 - breaks oauth-ng #149

jwmapana opened this issue Feb 28, 2017 · 7 comments

Comments

@jwmapana
Copy link

You get this error:

$http.get(...).success is not a function

@Luwangel
Copy link

Luwangel commented Mar 3, 2017

Alfsig fixed this in the PR #145 , but it seems that nobody cares.

@jwmapana
Copy link
Author

jwmapana commented Mar 3, 2017

I care! Sorry I didn't see this.

@salcedogeiner
Copy link

how i can update this fixed???

@afredericks
Copy link

Was this ever fixed?

@jwmapana
Copy link
Author

Luwangel says yes. It's been a while. I ended up going a different path with oauth.

@afredericks
Copy link

@jwmapana -- what path did you end up taking? I am trying to get oauth working with an angularjs client, I tried using this library but there seems to be too many issues with the latest version of angularjs.

@jwmapana
Copy link
Author

jwmapana commented Oct 3, 2017

I found a nice workable answer here:

https://stackoverflow.com/questions/18218293/angularjs-oauth/23490076

It's the solution that starts with "Here is a simple example using just redirects with angular js".

My login page has a controller with the login button tied to this function:

$scope.login_oauth2 = function() {

  var absolute_url = $location.absUrl();
  // I like to use a globalFactory that is included in every controller instead of touching $rootScope, for the most part:
  globalFactory.redirect_uri = absolute_url.replace('/#/login', ''); 
  var url_split1 = absolute_url.split('//');
  var url_split2 = url_split1[1].split('/');
  var url_split3 = url_split2[0];

	var scope="email";
	var redirect_uri=globalFactory.redirect_uri;
	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;
  // console.log('redirect url: ', url);
	window.location.replace(url); //this is where it goes to google oauth and gets the accessToken
};

====================
I retrieve the accessToken by creating a controller with no view in a controller called 'accessToken'

app.controller('accessToken', function ($location,$rootScope,globalFactory) {
var hash, splitted, params, param, key, value, authorized;

hash = $location.path().substr(1);

splitted = hash.split('&');
params = {};

for (var i = 0; i < splitted.length; i++) {
param = splitted[i].split('=');
key = param[0];
value = param[1];
params[key] = value;
$rootScope.accesstoken=params;
}

$location.path("/login"); //this can go to any route you want of course

});

and then put in a route like this, so when the site returns from google with a token, it processes it in the accessToken route:
$routeProvider
.when('/access_token=:accessToken', { //of course this is just one of the routes...
template: '',
controller: 'accessToken'
})

What happens is, your login view and controller sends the user to google oauth, they authenticate, and google oauth returns to your site with the access token, so your router takes you to this controller, which parses out the results. You can do pretty much whatever you want with it from there. I hope that helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants