I am writing a Web Api (using asp.net Web Api) and naturally want clients to authenticate to use the service.
I was hoping to write a Javascript plugin that would make use of the Api and then make it available to be simply dropped into other web sites.
Is there a secure way I can have the plugin authenticate?
I’m not sure how I could keep any information passed to the plugin confidential.
I also want the API to be used by native apps, so does that rule anything making use of cookies?
Thanks
You are going to have to either embed the username/password in your plugin OR have some fields to get that information from the user.
Consider some code if you choose to embed the username/password:
note the assignment of
beforeSendtosetHeader:}
Note, you will have to pre-calculate the auth string using the method below
Now if you want to pull the username/password from the user you could do this: