sureshchahal / angular2-adal

Angular 2 wrapper for adal.js
MIT License
41 stars 50 forks source link

Howto use AuthHttp in service to call external API #21

Closed rjwijnen closed 7 years ago

rjwijnen commented 7 years ago

I'm having difficulties on howto use the AuthHttp. Does anyone have examples using ng2-adal and calling secured external web api's? (With getting accestoken etc.)

fume commented 7 years ago

It's quite simple. Just inject AuthHttp instead of angular Http service and your request will contain the Authorization header. I don't have a public repo to show it, i'm sorry.

regards

slubowsky commented 7 years ago

Being new to Active Directory and adal, I had a really hard time getting it to work. I think most of my trouble was probably just wrong configuration. I finally got it to work by starting with the working angular 1 example at https://github.com/Azure-Samples/active-directory-angularjs-singlepageapp-dotnet-webapi. I then replaced just the API portion with my own, still using the angular 1 client, and then, once that was working I was able to get an angular 2 app working against it using the same configuration as in the angular 1 example

rjwijnen commented 7 years ago

Indeed it was quite simple and it was my config that was wrong with the endpoints part.. Thanks for the help!