Dejan Strancar have the example ? El viernes, 5 de diciembre de 2014, 9:33:28 (UTC-5), Dejan Strancar escribió: > > Ive found a way to easily make basic authentication via $resource. > First you need to get Authentication key from API, so you should call > $http POST(with your username/password) to server. > If return is success just get authentication key as return, > fill $http.defaults.headers.common.Authorization variable with that key. > You can do $resource as it is described everywhere call after that and it > will work since $http is dependency of $resource. > > Hope that helps. > > On Tuesday, October 23, 2012 9:28:39 AM UTC+2, Tom Bestebreurtje wrote: >> >> +1 from me on this. >> >> Requests with credentials are only mentioned once in Angular's $http docs: >> http://docs.angularjs.org/api/ng.$http >> >> - Tom >> >> On Wednesday, October 10, 2012 4:39:10 PM UTC+2, Roberto MartÃnez wrote: >>> >>> Hi Rameesh >>> >>> I wonder if you figured the solution of this. I'm trying to build >>> something like you mentioned. Thanks! >>> >>> >>> >>> On Saturday, July 7, 2012 7:20:49 PM UTC-4, Rameesh wrote: >>>> >>>> Thank you very much for the direction, that helped. >>>> >>>> I'm now looking for changing the header at runtime. For instance, a >>>> user enter a name/password pair and I need to pass that through a header >>>> before I hit the $resource call. Any ideas on that? >>>> >>>> Rameesh >>>> >>>> On Saturday, July 7, 2012 6:09:53 PM UTC+2, Noah Freitas wrote: >>>>> >>>>> I can't answer your Basic Authentication question, but I did recently >>>>> have to set a custom header on all $resource calls from my application: >>>>> >>>>> .config(['$httpProvider', function($httpProvider) { >>>>> $httpProvider.defaults.headers.common['X-Auth'] = apiKey; >>>>> }]); >>>>> >>>>> The $httpProvider.defaults.headers object is probably where you are >>>>> going to find your solution. The common object will set headers for all >>>>> $http requests, though you can be more granular and set them for specific >>>>> methods as well (GET, POST, etc.) >>>>> >>>>> The documentation can be found here: >>>>> http://docs.angularjs.org/api/ng.$http under "Setting HTTP Headers". >>>>> >>>>> On Friday, July 6, 2012 6:59:34 PM UTC-7, Rameesh wrote: >>>>>> >>>>>> How can I use the $resource service to call RESTful resources that >>>>>> requires Basic Authentication? How can I pass the user/password? Any >>>>>> links/posts/ideas are really appreciated. >>>>>> >>>>>> A more general question: How I can define the Request Headers while >>>>>> using $resource? >>>>>> >>>>>> Forgive the newbie questions. A couple of weeks and you'll find me >>>>>> answering similar questions myself :) >>>>>> >>>>>> Rameesh >>>>>> >>>>>
-- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
