Base64 encoding in Sproutcore

2.4k Views Asked by At

I need to invoke restful webservices in Sproutcore which requires authentication header for http request. I write a code like in Sproutcore:

authHeader: function () {
    var userAndPass = "username:password";
    var auth = "Basic " + Base64.encode(userAndPass);
    return auth;
},

However, when I run it, sadi Base64 is not defined.

Anybody knows how to fix it or do it in sproutcore. Thanks

1

There are 1 best solutions below

1
On BEST ANSWER

Use btoa() for Base-64 encodeing.

var auth = "Basic " + btoa(userAndPass);