From 46aa6caaaa1a0f1ec3fd567e47fcb0116270b37c Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Thu, 28 Nov 2024 21:33:30 -0800 Subject: [PATCH] Link to more demos --- cloudflare/workers-github-oauth.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cloudflare/workers-github-oauth.md b/cloudflare/workers-github-oauth.md index 6d39db146..461f9b72c 100644 --- a/cloudflare/workers-github-oauth.md +++ b/cloudflare/workers-github-oauth.md @@ -123,6 +123,8 @@ The last step was to configure that URL. I navigated to my `simonwillison.net` C That final `*` wildcard turned out to be necessary to ensure that `?code=` querystring URLs would also activate the `/github-auth` worker - without that I got a 404 served by GitHub Pages for those URLs instead. +Here's the deployed page - visiting it should redirect you straight to GitHub: https://tools.simonwillison.net/github-auth + ## Using this from an application The OAuth flow works by setting a `github_token` key in `localStorage()` for the entire `tools.simonwillison.net` domain - which means JavaScript on any page can check for that key and make API calls to the GitHub Gist API if the key is present. @@ -160,6 +162,8 @@ authLink.addEventListener('click', () => { Clicking the link also starts a every-second poll to check if `github_token` has been set in `localStorage` yet. As soon as that becomes available the polling ends, the "Authenticate with GitHub" UI is hidden and a new `saveGistBtn` (a button to save a Gist) is made visible. +Here's the page that uses that: https://tools.simonwillison.net/openai-audio-output - you'll need to provide an OpenAI API key and submit a prompt in order to see the option to Authenticate with GitHub. + ## Adding error handling That code Claude wrote is missing an important detail: error handling. If the GitHub API returns an error - e.g. because the `?code=` is invalid - the page won't reflect that to the user.