AngularJS + OAuth

I am trying to write a solution to enter an Angular app,
This means that the user can directly connect via Facebok / Google / Twitter or register.
I found Angular-OAuth to be useful, but it didn't seem to work with Facebook (or Twitter).

Does anyone know of a comprehensive solution for this?

+46
angularjs oauth
Aug 13 '13 at 20:08
source share
4 answers

Take a look at oauth.io

  • Simple implementation in javascript
  • 80+ OAuth Providers
  • Fast and safe
+38
Sep 03 '13 at 2:27
source share

Here is a simple example using only redirects using angular js

Here's how to redirect to authentication

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); }; }); 

Here's how to handle redirection after authentication

 angular .module('angularoauthexampleApp', [ ]) .config(function ($routeProvider) { $routeProvider .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"); } }) }); 

More complete information here http://anandsekar.imtqy.com/oauth2-with-angularjs/

+49
Sep 25 '14 at 5:14
source share

There is an alternative to Free-Open-Source for freemium oauth.io : hello.js

+13
May 6 '14 at 8:51
source share

Check out the Satellizer project on Github. I'm just starting with this, it seems promising.

It uses JSON Web Tokens and allows login with: email + password, Facebook, Twitter, Google and any other OAuth 1.0 / 2.0 provider.

Client code works in this field, you will have to implement the server part yourself. There are good descriptions of workflows and code examples for many server languages.

+6
Jul 02 '15 at 23:08
source share



All Articles