Flair API missing_authorization
I am writing an apps script to record data from Flair Pucks into a google Sheet. I have successfully connected using oAuth and have received an access token. I am having trouble using that token to get data from the sytem however.
Here is the code that I am using to form the request to get users. the ACCESS_TOKEN is the one derived from the oAuth previously, example: 9k55fr6Z04c9axjSMTxkFMSjWFu2cW
function getUsers(ACCESS_TOKEN){
var accessToken = ACCESS_TOKEN;
var flairURL = 'https://api.flair.co/api/users';
var options = {
'method' : 'get',
'Content-Type' : 'application/x-www-form-urlencoded',
'Accept' : 'application/json',
'Authorization' : 'Bearer ' + accessToken
}
var response = UrlFetchApp.fetch(flairURL, options);
Logger.log(response);
}
Here is the response I am receiving:
Exception: Request failed for https://api.flair.co returned code 401. Truncated server response: {"errors": [{"title": "missing_authorization", "status": 401, "detail": "Missing \"Authorization\" in headers."}]} (use muteHttpExceptions option to examine full response)
Not sure where I am making the mistake.
-
Hi Patrick,
I asked the team and the suggestion was that you need to define the headers and then Authorization as a sub-header.var options = {
'headers' : { 'Authorization' : 'Bearer ' + accessToken},
.
.
.
}
If you have additional questions I'd suggest pinging our support team but hopefully this helps if you are still stuck!
Cheers,
Dan
Please sign in to leave a comment.
Comments
1 comment