PayPal Subscriptions

I am trying to get a PayPal access token using the instructions at this URL:

I have followed the instructions at the URL to the letter and have built the following sample code in JavaScript. When I run it I get a 401 error - user not authorized.

<!DOCTYPE html>
    <meta charset="utf-8" />
    <h1>Get Access Token</h1>
        var xhttp = new XMLHttpRequest();
        xhttp.onreadystatechange = function () {
            if (this.readyState == 4 && this.status == 200) {
            else {
               console.log("Status: " + xhttp.status)
        url = ""
        clientID = "AY_6HpYodeIdCyCSWmIuTTX6P4PfcO1tcehekaSk9uwSBhav1SILCD0MZ_E3dRMVXiPdmE-YimahYtQy"
        secret = "EHLlKnunCQtuTdqjnl6QX9ZnuQgMllZKozf-VNHeys9tDssQc0xlXi4_0se1M-VxT8gOHGaSVS3M-2an""post", url, false, clientID, secret);
        xhttp.setRequestHeader("Accept", "application/json");
        xhttp.setRequestHeader("Accept-Language", "en_US");
        xhttp.setRequestHeader("content-type", "application/x-www-form-urlencoded");

The clientID and secret came from the PayPal My Apps and Credentials link:

PayPal My Apps and Credentials Page

Can anyone help? Thanks