0

I am trying to use pub-sub method to subscribe to the events of a specific user. I am able to successfully authenticate the user but when I call the pub-sub url I get the following error.

{"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":{}}

Code: This code is called inside the success callback of the OAuth2.0 Authentication.

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));
     }
)
  • 1
    This is the error response you get when your accessToken is invalid/missing. Are you able to use the same accessToken for other API calls? – RAY Nov 30 '16 at 19:36
  • Like I said above this is called inside the success callback method of OAuth 2.0. Inside the method I am using the access token that I received. So how would it be invalid? Just before this call I called a GET on User Endpoint with the same access token and it was a success. – Pushparaj Samant Dec 01 '16 at 04:14
  • If you manually POST to the pubsub endpoint with this accessToken, what response do you get? – RAY Dec 01 '16 at 18:09
  • Tried I get the following{ "meta": { "code": 401, "error_detail": "You must be logged in to perform that action", "error_type": "authentication_error", "message": "Unauthorized" }, "data": {} } – Pushparaj Samant Dec 02 '16 at 05:57
  • And that's the same token you can successfully use to get user data? Could you email apisupport @ jawbone.com with your client id and the token, so we can debug further? – RAY Dec 02 '16 at 18:03
  • Sure Ray Thanks for the help. Will send in a support request. – Pushparaj Samant Dec 05 '16 at 02:11

1 Answers1

0

The issue is not Jawbone API. The problem was in the angular $http method. For some reason with the above code it is not sending the headers at all so the OAuth error. It works fine when I use the below code.

$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));
    }
)

Thanks Ray for all the help.