Skip to content

Instantly share code, notes, and snippets.

View jamesmcintyre's full-sized avatar

James McIntyre jamesmcintyre

View GitHub Profile
@jamesmcintyre
jamesmcintyre / oauth.ts
Created October 21, 2018 15:15 — forked from DennisAlund/oauth.ts
Firebase cloud function for OAuth handshake in medium article https://medium.com/evenbit/151c1c98641d
export const oauth_redirect = functions.https.onRequest(async (request, response) => {
if (request.method !== "GET") {
console.error(`Got unsupported ${request.method} request. Expected GET.`);
return response.send(405, "Only GET requests are accepted");
}
if (!request.query && !request.query.code) {
return response.status(401).send("Missing query attribute 'code'");
}
@jamesmcintyre
jamesmcintyre / cloudflareworker-verifyjwt.js
Created December 6, 2023 06:27 — forked from bcnzer/cloudflareworker-verifyjwt.js
Sample Cloudflare worker that gets the JWT, ensures it hasn't expired, decrypts it and returns a result
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
// Following code is a modified version of that found at https://blog.cloudflare.com/dronedeploy-and-cloudflare-workers/
/**
* Fetch and log a request
* @param {Request} request
*/