0

I am builsing my application with angularjs and in my application I am calling a rest api where I need to pass user name and password as a user credential, I am making both get and post operation using $http. Now where I will give my user credential details when calling the webservice.Please suggest some example and usefull links.

Thanks and Regards

Utpal

Utpal
  • 805
  • 4
  • 15
  • 44

1 Answers1

1

One way, as described here ng.$http , could be:

$http.get(url, { withCredentials: true, });

An extract:

withCredentials - {boolean} - whether to to set the withCredentials flag on the XHR object. See requests with credentials for more information.

Radim Köhler
  • 122,561
  • 47
  • 239
  • 335
  • But how can I set the credentials when sending the request.Will I need to append it in URL or there is any other way. What will be the option in the case of POST operation. – Utpal Jan 22 '14 at 11:11
  • get, post, put all operations are the same. In this case, without doing anything else, we are passing by the windows credentials for example (no custom authentication). If you need custom authentications... search for it. This setting will properly append credentials to all your requests – Radim Köhler Jan 22 '14 at 11:16
  • Hi thank u all for your responses but can anyone give me a sample example or link. – Utpal Jan 22 '14 at 11:31
  • I am mostly using windows, but why not start here http://stackoverflow.com/questions/16139660/ and then http://www.frederiknakstad.com/authentication-in-single-page-applications-with-angular-js/ – Radim Köhler Jan 22 '14 at 11:34