Search code examples
javascripthttpssproutcore

Basic Authentication in SproutCore SC.Request


Thanks to IAbstractDownvoteFactory for an awesome answer to my previous question

Connecting to an HTTPS service with SproutCore

This question is based off that. My question being, the server needs me to log in. Now, for dev reasons, I don't need the user to fill out the form. Additionally, even when this app is released, the user will NOT need to log in.

Thus, the username and password is only for dev purposes. However, it is there, and I don't want to see the browser popUp window. Is there any way in which I can handle authentication in the callback function?

Again, any help will be greatly appreciated! :D


Solution

  • SC.Request supports the header(key, value) function so you can try injecting the basic authentication header yourself.

    Set the key to "Authorization" and the value to base64_encode("username:password").

    Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==