Skip to main content
Account
Lesson 9 of 9

Configuring OAuth Providers (Google, GitHub, etc.)

Integrate third-party OAuth providers like Google, GitHub, and Microsoft for social login, configure client IDs, secrets, and scopes

Configuring OAuth Providers (Google, GitHub, etc.)

Connecting Zitadel with External OAuth Providers

Welcome back to the Complete Guide to Zitadel. In this video, we’ll explore how to connect your Zitadel instance to external OAuth providers, allowing users to log in using their existing accounts from services like GitHub, Google, Microsoft, and more.

While this tutorial uses GitHub as the example, the principles apply to any OpenID Connect provider - whether that’s Google, Microsoft, Okta, Auth0, or any other service that supports OAuth 2.0.

Understanding Identity Provider Configuration

Zitadel offers two levels for configuring identity providers:

  1. Instance Level (Default Settings): Providers configured here are inherited by all organizations
  2. Organization Level: Each organization can have its own identity provider configuration

Setting Up GitHub OAuth

Step 1: Create a GitHub OAuth Application

First, we need to create an OAuth application in GitHub:

  1. Navigate to your GitHub Developer Settings
  2. Click New OAuth App
  3. Fill in the application details:
    • Application Name: Your app name (e.g., “Zitadel Demo”)
    • Homepage URL: Your application URL
    • Authorization callback URL: Copy this from Zitadel’s setup screen
  4. Click Register application
  5. Note your Client ID
  6. Generate a new Client Secret (save this securely - you’ll only see it once!)

Step 2: Configure GitHub in Zitadel

In the Zitadel console:

  1. Navigate to Organizations → Your Organization → Login and Access
  2. Click Identity Providers → Add Provider → GitHub
  3. Enter your GitHub OAuth app credentials:
    • Client ID: From GitHub
    • Client Secret: From GitHub
    • Scopes: Configure based on your needs
  4. Configure the provider settings

Understanding OAuth Scopes

When configuring GitHub (or any OAuth provider), you need to specify which scopes your application requires. For GitHub:

  • read:user - Read access to user profile data
  • user:email - Access to user email addresses

For other providers, common scopes include:

  • Google: openid, profile, email
  • Microsoft: openid, profile, email, offline_access
  • Auth0: openid, profile, email

Provider Configuration Options

Display Name

This is what users will see on the login button (e.g., “GitHub Demo” or “Sign in with GitHub”)

Account Creation

  • Automatic creation: Enable to automatically create Zitadel accounts for new users
  • Account update: Update user information from the provider on each login
  • Account linking: Merge accounts with matching email addresses

The GitHub Name Challenge

GitHub presents a unique challenge: it doesn’t provide separate first and last name fields in its user profile. Instead, it returns a single name field. Since Zitadel requires both first and last names for account creation, we need to handle this.

Solution: Zitadel Actions

Zitadel Actions allow you to customize the authentication flow. Here’s how to automatically split the GitHub name:

function updateGitHubUser(ctx, api) {
// Check if this is a GitHub login
if (ctx.v1.externalIdp?.id !== 'YOUR_GITHUB_IDP_ID') {
return;
}
// Get the full name from GitHub
const fullName = ctx.v1.externalIdp?.rawInfo?.name || '';
// Split the name intelligently
const parts = fullName.trim().split(' ');
if (parts.length === 0) {
return;
}
// Set first name and last name
if (parts.length === 1) {
api.v1.user.setFirstName(parts[0]);
api.v1.user.setLastName(''); // Or use a placeholder
} else {
api.v1.user.setFirstName(parts[0]);
api.v1.user.setLastName(parts.slice(1).join(' '));
}
}

Implementing the Action

  1. Go to Actions in the Zitadel console
  2. Click New Action
  3. Name it (e.g., “Update GitHub User”)
  4. Paste the action code
  5. Replace YOUR_GITHUB_IDP_ID with your actual GitHub IDP ID (found in the URL)
  6. Save the action
  7. Add a trigger for Post Authentication

Testing the Integration

Once configured:

  1. Log out of Zitadel
  2. Go to the login page
  3. You’ll see your new provider button (e.g., “Sign in with GitHub”)
  4. Click it to authenticate
  5. Authorize the application in GitHub
  6. You’ll be redirected back to Zitadel and logged in

First-Time Login Flow

For new users:

  1. They authenticate with the external provider
  2. If account creation is automatic, Zitadel creates their account
  3. If the action is configured, it processes user data
  4. The user is logged in to your application

Returning User Flow

  1. Click the provider button
  2. If still authenticated with the provider, immediate redirect
  3. Otherwise, authenticate with the provider
  4. Return to your application

Google

  1. Create a project in Google Cloud Console
  2. Enable Google+ API
  3. Create OAuth 2.0 credentials
  4. Add authorized redirect URI from Zitadel
  5. Configure in Zitadel with scopes: openid profile email

Microsoft (Azure AD)

  1. Register an application in Azure Portal
  2. Add a redirect URI (Web platform)
  3. Create a client secret
  4. Configure in Zitadel with tenant information
  5. Use scopes: openid profile email offline_access

Auth0

  1. Create an application in Auth0 Dashboard
  2. Set callback URL from Zitadel
  3. Note domain, client ID, and secret
  4. Configure in Zitadel with your Auth0 domain

Multiple Identity Providers

You can configure multiple identity providers simultaneously:

  • Users can choose their preferred login method
  • Accounts can be linked if emails match (when configured)
  • Different organizations can have different provider sets
  • Providers can be enabled/disabled without data loss

Actions v2 Preview

Security Considerations

Client Secret Management

  • Store secrets securely
  • Rotate secrets regularly
  • Never commit secrets to version control
  • Use environment variables or secret management tools

Scope Management

  • Request minimal necessary scopes
  • Review scope requirements regularly
  • Document why each scope is needed
  • Consider user privacy implications

Account Linking

  • Only link accounts with verified emails
  • Consider the trust level of each provider
  • Implement additional verification for sensitive operations
  • Log account linking events for audit trails

Troubleshooting Common Issues

“External user not found”

This occurs when:

  • Automatic account creation is disabled
  • The action fails to set required fields
  • There’s a mismatch in expected user data

Redirect URI Mismatch

  • Ensure the callback URL in your provider matches exactly
  • Check for trailing slashes
  • Verify HTTP vs HTTPS
  • Confirm the correct Zitadel instance URL

Missing User Information

  • Check the requested scopes
  • Verify the provider returns expected fields
  • Use actions to transform or supplement data
  • Review provider-specific documentation

Best Practices

  1. Start Simple: Begin with one provider and expand
  2. Test Thoroughly: Test new user registration and returning user flows
  3. Document Configuration: Keep records of client IDs, scopes, and settings
  4. Monitor Usage: Track which providers users prefer
  5. Plan for Failures: Have fallback authentication methods
  6. Regular Audits: Review provider configurations and permissions

Summary

Connecting external OAuth providers to Zitadel is straightforward:

  1. Create an OAuth application with your provider
  2. Configure the provider in Zitadel with credentials and scopes
  3. Handle any provider-specific quirks with Actions
  4. Test the complete authentication flow

With just a few clicks, you can offer users authentication through GitHub, Google, Microsoft, LinkedIn, Stack Overflow, and dozens of other providers. This reduces friction in the registration process and lets users leverage their existing accounts.

In the next video, we’ll explore more advanced authentication patterns and dive deeper into Zitadel Actions for customizing your authentication flows.

Transcript

Generated from English captions. Select a timestamp to jump to that moment.

0:00 David Flanagan: Welcome back to the Complete Guide to Zitadel. In this video, we will be taking a look at how to connect our Zitadel instance to a GitHub O application, allowing us to log into our Zitadel instance using our GitHub credentials. This tutorial is not specific to GitHub in any way other than the fact that I will be using GitHub, but you can make this work for any open Id connect provider, whether that'd be Google. Microsoft, Okta osteo, anything you like. So let's get straight to the demo and get hands on the keyboard. Let's see you in a second.

0:44 So here we are again back at ADE Console. As always, we click on projects. We have our Rawkode Academy project, we click on it. Nothing has changed from the previous video, however, and just like the previous video, we're gonna jump straight in by going to the default settings where we could pop down and add an identity provider here. Now, I don't wanna spend too much time on this right now because we are probably doing B2B multi-tenants Zitadel videos later on in this course. But by adding a, an identity provider as a default setting, this will

1:21 be inherited by all organizations. The other approach would be to click on organizations and modify the login and access for the Rawkode Academy organization. We can click on identity providers, we can click on GitHub, and now we need to add a client ID in SEC group. Now I have our GitHub set up here where I am logged in as myself on my own personal developer sentence where I can add a new OAuth application. You can do this at the organization level if you wish. We can click a new OAuth app and I will call this Zitadel demo, and I'm just

2:02 gonna say that lives at Zitadel dot com. It is asking us for the callback URL, and if we come back here, we can copy that from the Zitadel setup screen like so we register the application, we grab our client id, we paste it, and then we generate a new client secret rib. You rather only see this once, so make sure you store it somewhere safe. Now we could click create and save that, but you will want to modify the scope list potentially depending on what information from the GitHub user your application needs. Now, the default setup for working with GitHub is not profile or email at all.

2:51 You can search for GitHub, user scopes, OAuth, where here you'll see that we have access to read user and user email right in the middle of the screen. So we'll add read, user and user email. You can give us a name, so we'll call this GitHub demo. This is what it'll be called on the button when we try to register or login with our account. Now in order to allow anyone to register, you will have to allow automatic creation of new accounts. And if you wish, you can have an update every time the user re logs in.

3:31 Just depends whether you want to sync their GitHub username to your Zitadel system. You can even choose to merge accounts, or at least consolidate them when they have the same username or same email. Typically, I check for the same email existing in the system and say that that is safe to merge. And then we click Create and save, and we're done. We click the activate button here and that should be us. We can head over to the login page for the Zitadel Council. And then we have the option to register or log in with GitHub demo.

4:16 So we can click register, select GitHub demo, or it can log in with my Paki. And authorized Dell demo. We can see the only information it's gonna get from my account is just to understand my email address and my profile information, to which I can say, yes, I'm happy with this. It will redirect to our URL and we are presented with a external user not found. Do you want to link or create? Now this is very specific to GitHub and I'll get into why in just a moment, but for now, let's just say David Flanagan.

4:57 Raw code, email address, and accept like, so I will skip the second factor, and we are logged in. Now I am going to log out just so we can go through the login flow. All right, I see your login is GitHub, select my account again. And the job is done. So walk with with that little intermediate step where we need to provide our name for the account registration. Well, we can head over to the Zitadel documentation where we have this optional section on the page called Configured GitHub as an identity provider. Now, what happens is when we use GitHub as the identity provider, we can't actually

5:57 create an account that doesn't have a first name and a last name, so this needs to be provided or configured by the user. Or we can use something called Zitadel actions. Now we will begin into Zitadel actions in more detail with more use cases and subsequent videos. But I will show you how to fix this for GitHub right now. And the code is attached as a resource to this video, so don't worry about pausing it and trying to type it all down. Just copy and paste it right over there. Now they provided an example here, but as I use Zitadel in production for

6:30 the Rockwood Academy, I have my own version of this with a few extra checks. So I'm gonna use that. So we can click on actions. We select new and we give it a name. We'll just call this get Update GitHub user. I'm going to paste in the code verbatim from my production instance. The only thing we really need to do is come here and update the ID for the external IDP. So for that I can duplicate the tab, give it a moment. You can go to organization, login identity providers. Click on GitHub and then Id is in the URL.

7:23 We can drop that in here. And you'll see that this is just getting the full name from the response from the GitHub, API, the callback. It splits it on a space, which is a little bit crude, but we're just assuming that we split on any space. We will get some version of the full name and surname. We do check that the length of the parts, so we set one for the first name and then the rest of it for the last name. And then if they only have one part. We just leave the last name empty.

7:57 We can click add that saves our action, and then we can add a trigger or post authentication to update the user like so. It just means if we go to users, find my GitHub account, we'll just confirm that this is the GitHub demo, IDP. And we'll delete that user. We can now come over here and hit refresh where I should be logged out. That's good. So we can click register. We slide GitHub, we accept and we skip. No mail, no manual entry. My first name, Ms. R. Name her set. Perfect. Now there is one caveat to this.

8:53 You may have noticed when we clicked on actions that it does talk about an actions V two. So this is the original V one version of actions that we're using right now. There is a more sophisticated approach to handling events and functions within your digital instance. And as I like to say, there are more comprehensive videos in this course as we explore the full feature set of Zitadel. So while I'm not covering it in this video. We will be covering it soon. And that's it. Again, everything is simple when you know how you can add as many

9:28 identity providers as you need. So go set up LinkedIn, Google, GitHub, Microsoft, Okta of zero Stack overflow. I don't know, go nuts. The world is your oyster. And just a few clicks, you can have third party authentication connected to your digital instance, allowing your users to connect no matter where they're coming from. We'll see you in the next video. Until then, have a great day.

Course curriculum (9 lessons)
  1. 01. Introduction
  2. 02. Prerequisites
  3. 03. How to Install Zitadel with Docker Compose (Step-by-Step)
  4. 04. Installing Zitadel on Kubernetes with Helm
  5. 05. Zitadel Cloud
  6. 06. Your First Application
  7. 07. Integrating with an Astro Application
  8. 08. Passwords, Passkeys, and MFA
  9. 09. Configuring OAuth Providers (Google, GitHub, etc.)

Loading optional course email signup. If it does not load, reload this lesson to retry. Signup requires JavaScript; all lesson content remains available without signing up.