I'm trying to access the twitter API using a plain old XMLHttpRequest. And it's not working. I've tried the obvious things (refreshing my credentials, etc). 

Any ideas? Does Twitter not allow client-side API access???

```
function getAccessToken () {
    var secret = encodeURI("xxx");
    var key = encodeURI("yyy");
    var keyAndSecret = key + ":" + secret;
    var encoded = btoa(keyAndSecret);

    var authRequest = new XMLHttpRequest();
    authRequest.open("POST", "https://api.twitter.com/oauth2/token");
    authRequest.setRequestHeader("Authorization", "Basic " + encoded);
    authRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
    authRequest.onreadystatechange = function () {
        if (authRequest.readyState == 4) {
            var accessToken = JSON.parse(authRequest.response);
            console.log("access token:", accessToken);
        }
    }           
    authRequest.send("grant_type=client_credentials");

}

```