0

I have handled the process to get a valid access token;

nevertheless, now I am stuck to get data from the server;

I have checked the forum and other web pages, but I could not figure out what I am doing wrong;

I am running the following Google Application Script:

var jawbone_access_token = "my private access token - long string";
var options = {
                 'Accept'        : 'application/json',
                 'Authorization' : 'Bearer ' + jawbone_access_token
                }

var jawbone_request = "https://jawbone.com/nudge/api/v.1.1/users/@me";
response = UrlFetchApp.fetch(jawbone_request, options).getContentText(); 
writeLog(response); 

nevertheless, I always get the following response:

ERROR - Stau:Exception: Fehler bei der Anfrage für https://jawbone.com/nudge/api/v.1.1/users/@me. Folgender Code wurde zurückgegeben: 404. Gekürzte Serverantwort: {"meta": {"error_detail": "Unsupported API version 1.1, unless called with an OAuth header", "code": 404, "error_type": "endpoint_error", "time": 1.... Verwenden Sie "muteHttpExceptions", um die vollständige Antwort zu lesen.

can you please help me to figure out what I am doing wrong;

Thank you very much in adavance for your help;

Best Regards Rudolf

eli-k
  • 10,898
  • 11
  • 40
  • 44

1 Answers1

0

That is the response you get when you haven't provided the Access Token in the header.

I took a quick look at the UrlFetchApp documentation, and you need to put your headers in a headers object:

var options = {
    'headers': {
        'Accept': 'application/json',
        'Authorization': 'Bearer ' + jawbone_access_token
    }
}
RAY
  • 474
  • 4
  • 21