0

我正在尝试使用 pub-sub 方法订阅特定用户的事件。我能够成功地对用户进行身份验证,但是当我调用 pub-sub url 时出现以下错误。

{"meta":{"error_detail":"Unsupported API version 1.1, unless called with an OAuth header","code":404,"error_type":"endpoint_error","time":1480394928,"message":"Not Found","user_xid":""},"data":{}}

代码:此代码在 OAuth2.0 身份验证的成功回调中调用。

var subscription_url = "https://jawbone.com/nudge/api/v.1.1/users/@me/pubsub?webhook=https://*****/pushJawbone";
$http.post(
    subscription_url, {
       headers: {
        'Authorization': "Bearer " + accessToken
       }
    }
).success(
    function(response) {
       console.log("Jawbone User Subscription Successful" + response);
    }
).error(
    function(error) {
       console.log("Jawbone sub unsucessful: " + JSON.stringify(error));
     }
)
4

1 回答 1

0

问题不在于 Jawbone API。问题出在角度 $http 方法中。由于上述代码的某种原因,它根本没有发送标头,因此出现 OAuth 错误。当我使用下面的代码时它工作正常。

$http({
     method: 'POST',
     url: subscription_url,
     headers: {
          'Authorization': 'Bearer ' + accessToken
     }
}).success(
    function(response) {
         console.log("Jawbone User Subscription Successful" + response);

    }
).error(
    function(error) {
         console.log("Jawbone sub unsucessful: " + JSON.stringify(error));
    }
)

感谢雷的所有帮助。

于 2016-12-08T12:02:14.760 回答