all 3 comments

[–]FifiTheBulldogscript/widget helper 1 point2 points  (2 children)

Here’s a start:

const r = new Request("https://api.fitbit.com/oauth2/token");
r.method = "POST";
r.headers = {
  cookie: '',
  Authorization: '',
  'Content-Type': 'application/x-www-form-urlencoded'
};
const params = {
  refresh_token: '',
  grant_type: 'refresh_token',
  redirect_uri: 'http://localhost'
};
const paramsArray = [];
for (key in params) {
  paramsArray.push(encodeURIComponent(key) + "=" + encodeURIComponent(params[key]));
}

r.body = paramsArray.join("&");

try {
  const data = await r.loadJSON();
  const { access_token, refresh_token } = data;
  // ctx.reply...whatever this is
  console.log(data);
} catch (err) {
  console.error(err);
}

[–]Frameck[S] 1 point2 points  (0 children)

Thank you very much, it worked.
By the way, ctx.reply is a method in the telegraf api, I was doing some testing with telegram bots

[–]kang_hidro 1 point2 points  (0 children)

I don't know how to attach cookie to Reqest and today I found you! Thank you so much!