Basic Auth with Ionic and Angularjs?

Asked

Viewed 132 times

0

I am a native Android/iOS developer and am now starting to study Ionic for hybrid development. I need to make a connection with a webservice that uses Basic Auth and I’m not finding how to do this, I found some examples with a lot of code written, for example this: http://devdactic.com/user-auth-angularjs-ionic/ and yet it doesn’t use Basic Auth. I believe it’s something simple, but I’m not finding.

How to do this ?

  • It will be hard to find anyway. In hybrid applications development uses a lot the JSON Web Tokens to do auth, I’m having a similar problem, using a restful webservice made available by apex5 Workspace.

  • @devgaspa found this example http://jasonwatmore.com/post/2014/05/26/AngularJS-Basic-HTTP-Authentication-Example.aspx I’m trying to implement, something put here.

1 answer

1


Try this:

$http.get('http://myserver.com/api', { headers: {'Authorization': 'Basic '+ base64.encode( username + ':' + password) } })

debug in Chrome Developer-Tools, Network tab

Browser other questions tagged

You are not signed in. Login or sign up in order to post.