I have a Google spreadsheet with a script to fetch Fitbit data that is working fine, but any other ones I have, which are the same in the parts that matter give me this error when I try to authorize: "We're sorry, a server error occurred. Please wait a bit and try again"
I have determined by using the logger that this occurs at the line:
var result = UrlFetchApp.fetch("https://api.fitbit.com/1/user/-/profile.json", options);
The whole code is here: https://jsfiddle.net/j72qbe08/ (this is mostly copied from code I found by searching online)
The code for the other existing spreadsheet that is still working also has the same error when I copy it into a new spreadsheet and try to authorize. But I wasn't starting from a new spreadsheet when I first had this error, it was an existing sheet that was working fine recently.
It's supposed to open a dialog saying "Authorization required" and then a window allowing you to log in to Fitbit. But it's not doing any of that.
Presumably it's something with the Google script editor because the other spreadsheet still works.
Thank you
EDIT: According to this page Google has deprecated support for OAuth1 and it's scheduled for shut down on April 20. It's only April 15, but maybe they did it early? Not sure if that explains anything. Fitbit API still not OAuth2 compatible
EDIT 2: "February 23, 2015: We will revoke a progressively larger number of access tokens on an ongoing basis, until most users are affected." Guess that might explain it.
If fitbit api only uses Oauth1 you can use this Oauth1 library to make the connection.
https://github.com/googlesamples/apps-script-oauth1
The readme.md shows how to set it up.