Change the organization to "Grafbase" from the top navigation.
Navigate to "Settings", click "Identity Providers", then "GitHub". To use GitHub as an authentication provider, create a new OAuth application in GitHub. Go to GitHub OAuth Apps, give the app a name and URL, and set the callback URL with the value from Zitadel. Now copy the client ID and the secret created in GitHub to the corresponding fields in Zitadel. Open optional settings, add the scope user:email
, and check all the checkboxes. Click "Save", scroll up, and click "Activate".
To fetch the user email via GitHub, navigate to "Actions" and click "New". Name the action as "backfillEmail" and fill it with the following snippet:
let http = require("zitadel/http")
function backfillEmail(ctx, api) {
const { human } = ctx.v1.externalUser
// This is an example of how email is added with GitHub auth
if (!human.email?.length) {
const emails = http.fetch('https://api.github.com/user/emails', {
method: 'GET',
headers: {
"Authorization": `Bearer ${ctx.accessToken}`
}
}).json()
const primaryEmailAddress = emails.find(email => email.primary)
if (primaryEmailAddress) {
api.setEmail(primaryEmailAddress.email)
}
}
}
Click "Add", then click the "Add trigger" button. Set the trigger type to "Post Authentication" and actions to "backfillEmail" and "backfillName". Click "Save".
Now navigate to the Grafbase Dashboard and log in with your GitHub credentials. The dashboard should prompt you to create a new organization.