Public
Edited
Oct 22
9 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
relmeauth_state.access_token
Insert cell
import { authorize_link as relmeauth_link, state as relmeauth_state } with {
RELMEAUTH_CLIENT_ID as CLIENT_ID,
RELMEAUTH_AUTHORIZE_URL as AUTHORIZE_URL,
RELMEAUTH_TOKEN_URL as TOKEN_URL,
RELMEAUTH_TOKEN_PARAMS as TOKEN_PARAMS
} from '@tomlarkworthy/oauth'
Insert cell
Insert cell
Insert cell
Insert cell
RELMEAUTH_TOKEN_PARAMS = args => ({
client_id: args.CLIENT_ID,
redirect_uri: args.REDIRECT_URI,
scope: args.SCOPES.join(" "),
code: args.code,
state: args.state
})
Insert cell
Insert cell
Insert cell
html`<a href="${github_link}">login to Github</a>`
Insert cell
github_state
Insert cell
import { authorize_link as github_link, state as github_state } with {
GITHUB_CLIENT_ID as CLIENT_ID,
GITHUB_CLIENT_SECRET_SECRET_NAME as CLIENT_SECRET_SECRET_NAME,
GITHUB_CLIENT_SECRET_PARAMETER_NAME as CLIENT_SECRET_PARAMETER_NAME,
GITHUB_AUTHORIZE_URL as AUTHORIZE_URL,
GITHUB_TOKEN_URL as TOKEN_URL,
GITHUB_TOKEN_PARAMS as TOKEN_PARAMS
} from '@tomlarkworthy/oauth'
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
GITHUB_REDIRECT_URI = deploy("github_storage_redirect", async (req, res) => {
// From the state parameter we can figure out the tenant that used it.
const tenant = (await firebase
.database()
.ref(`@tomlarkworthy/oauth-examples/${req.query.state}`)
.once('value')).val();
res.redirect(
`https://observablehq.com/@tomlarkworthy/oauth-examples?tenant=${tenant}&state=${req.query.state}&code=${req.query.code}#github_storage`
);
})
Insert cell
Insert cell
Insert cell
state_to_tenant = {
if (github_storage_state.state && tenant)
return firebase
.database()
.ref(`@tomlarkworthy/oauth-examples/${github_storage_state.state}`)
.set(tenant);
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
GITHUB_STORAGE_BACKEND = ({
getItem: async key => (await ref.child(btoa(key)).once('value')).val(),
setItem: async (key, value) => await ref.child(btoa(key)).set(value)
})
Insert cell
import {
authorize_link as github_storage_link,
state as github_storage_state
} with {
GITHUB_CLIENT_ID as CLIENT_ID,
GITHUB_CLIENT_SECRET_SECRET_NAME as CLIENT_SECRET_SECRET_NAME,
GITHUB_CLIENT_SECRET_PARAMETER_NAME as CLIENT_SECRET_PARAMETER_NAME,
GITHUB_AUTHORIZE_URL as AUTHORIZE_URL,
GITHUB_TOKEN_URL as TOKEN_URL,
GITHUB_TOKEN_PARAMS as TOKEN_PARAMS,
GITHUB_STORAGE_BACKEND as STORAGE_BACKEND,
GITHUB_REDIRECT_URI as REDIRECT_URI
} from '@tomlarkworthy/oauth'
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
import { authorize_link as reddit_link, state as reddit_state } with {
REDDIT_CLIENT_ID as CLIENT_ID,
REDDIT_CLIENT_SECRET_SECRET_NAME as CLIENT_SECRET_SECRET_NAME,
REDDIT_USE_BASIC_AUTH as USE_BASIC_AUTH,
REDDIT_AUTHORIZE_URL as AUTHORIZE_URL,
REDDIT_TOKEN_URL as TOKEN_URL,
REDDIT_TOKEN_HEADERS as TOKEN_HEADERS,
REDDIT_TOKEN_BODY as TOKEN_BODY,
REDDIT_SCOPES as SCOPES
} from '@tomlarkworthy/oauth'
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
html`<a href="${google_link}">login to Google</a>`
Insert cell
google_state
Insert cell
import { authorize_link as google_link, state as google_state } with {
GOOGLE_CLIENT_ID as CLIENT_ID,
GOOGLE_CLIENT_SECRET_SECRET_NAME as CLIENT_SECRET_SECRET_NAME,
GOOGLE_CLIENT_SECRET_PARAMETER_NAME as CLIENT_SECRET_PARAMETER_NAME,
GOOGLE_AUTHORIZE_URL as AUTHORIZE_URL,
GOOGLE_TOKEN_URL as TOKEN_URL,
GOOGLE_TOKEN_HEADERS as TOKEN_HEADERS,
GOOGLE_TOKEN_BODY as TOKEN_BODY,
GOOGLE_SCOPES as SCOPES
} from '@tomlarkworthy/oauth'
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
html`<a href="${strava_link}">login to Strava</a>`
Insert cell
strava_state
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
STRAVA_TOKEN_PARAMS = args => ({
client_id: args.CLIENT_ID,
redirect_uri: args.REDIRECT_URI,
scope: args.SCOPES.join(" "),
code: args.code,
state: args.state
})
Insert cell
import { authorize_link as strava_link, state as strava_state } with {
STRAVA_CLIENT_ID as CLIENT_ID,
STRAVA_CLIENT_SECRET_SECRET_NAME as CLIENT_SECRET_SECRET_NAME,
STRAVA_CLIENT_SECRET_PARAMETER_NAME as CLIENT_SECRET_PARAMETER_NAME,
STRAVA_AUTHORIZE_URL as AUTHORIZE_URL,
STRAVA_TOKEN_URL as TOKEN_URL,
STRAVA_TOKEN_PARAMS as TOKEN_PARAMS,
STRAVA_SCOPES as SCOPES
} from '@tomlarkworthy/oauth'
Insert cell
import { footer } from "@endpointservices/endpoint-services-footer"
Insert cell
footer
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more