Back
Version 11
1/12/2025
import { encode as base64Encode } from "https://deno.land/std@0.166.0/encoding/base64.ts";
import * as fbUtils from "https://esm.town/v/snowypowers/FitBitUtilities";
import { blob } from "https://esm.town/v/std/blob?v=12";
import { sha256 } from "https://esm.town/v/vtdocs/sha256";
const clientId = Deno.env.get("lifelog_fitbit_oauth_client_id");
const state = crypto.randomUUID().slice(0, 8);
const verifier = crypto.randomUUID().slice(0, 8);
/**
* Visit this url to get authorized for lifelog to collect data.
*/
export default async function(req: Request): Promise<Response> {
blob.set(`fibit_${state}`, verifier);
const url = await fbUtils.createAuthUrl({
clientId,
state,
verifier,
scopes: fbUtils.allScopes,
});
return Response.redirect(url);
}
snowypowers-lifelogfitbitauthorize.web.val.run
Updated: January 13, 2025