0

I have a REST service running on server.

I have Chrome Postman to access that service with Basic Authentication, and I can access that service with this Post man.

But, now I want to create a UI to show received data from REST in AngularJS. For this I tried

How I can call this REST service by using AngularJS with Basic Authentication? I have username and password.

Thanks, Ashok

Ashok
  • 197
  • 3
  • 17
  • Possible duplicate of [How do I get basic auth working in angularjs?](http://stackoverflow.com/questions/17959563/how-do-i-get-basic-auth-working-in-angularjs) – Johannes Jander Feb 16 '16 at 10:32

1 Answers1

0

To deal with the basic authorization there's an Angular module here: https://github.com/iandotkelly/angular-basicauth.

It supports:

  • Service for handling login and logout operations
  • Validates login against a configurable server endpoint defaulting to /api/authentication
  • Promise API for success/error on login
  • Broadcasts 'login', 'logout' and 'authentication-failed' events on $rootScope to allow all parts of the application to respond to auth events
  • Once logged in provides an $http interceptor to add Authorization http header to all requests
  • Stores username and authentication credentials in local-storage or cookies as a fallback
  • Automatically logs user out on failed authentication
  • Automatic logout after 3 hours (configurable)

However, there's drawbacks. The one I really do not like is:

Please note this module stores unencypted username & password in local-storage or cookies, so is susceptible to attack from code from the same domain.

Johannes Jander
  • 4,974
  • 2
  • 31
  • 46