AngularJS / OAuth 2 传输层安全

AngularJS / OAuth 2 transport-layer security

我试图从中获取响应的 OAuth 服务正在运行,但我的代码中出现错误,无法发出请求。

$http.post(myURL, 'grant_type=password&username=' + userName + '&password=' + passWord,
    headers: { 'Content-Type: application/x-www-form-urlencoded', 'Authorization Basic ' + btoa(secretWord) }).
        success(function (response) {
            console.log(response);
        }).
        error(function (response) {
            console.log(response);
        });

你有语法错误,因此 JS 不会发出 HTTP Post 请求,试试这个:

$http.post(myURL, 'grant_type=password&username=' + userName + '&password=' + passWord,
    { headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'Authorization': 'Basic ' + btoa(secretWord) } }).
        success(function (response) {
            console.log(response.data);
        }).
        error(function (response) {
            console.log(response.status);
        });