Skip to content
On this page

Single Sign-On (SSO)

Single Sign-On is a mechanism which allows to use external providers to login into systems. For example, you can use your Google or Facebook account to authenticate into systems without the need to create a new registration on those systems.

Supported SSO mechanisms

Directus supports four standard types of SSO mechanisms:

Here are the configuration allowed for each one: SSO configuration

In order to use these mechanisms you need to:

  1. Create an application/configuration on your preferred external provider
  2. Set the environment variables to configure the external provider
  3. [Optional] Set the environment variables to configure cookies


In this section, we provide some guides to help you set up SSO with OpenID.


To be able to use Google OpenID as your external provider you will need to:

  1. Go into Google Cloud Console

  2. Select or Create a new project

  3. Go to APIs & Services -> OAuth consent screen on side bar

    1. Select the access you desire
      • Select Internal if you only want people within your organization to be able to access
      • Select External to allow everyone with a Google account
    2. Fill the fields according to your preferences
      • The Authorized domains add an extra layer of security, but it is not required. In case you fill it, should be the domain where your Directus instance is
    3. On Scopes, you need to choose .../auth/, .../auth/userinfo.profile and openid
  4. On side bar, go to Credentials

  5. Click on Create Credentials -> OAuth Client ID

    1. Choose Web Application on Application Type
    2. The Authorized JavaScript origins adds an extra layer of security, but it is not required. In case you fill it, should be the address of your Directus instance. For example,
    3. On Authorized redirect URIs put your Directus instance address plus /auth/login/google/callback. For example, you should put where should be the address of your Directus instance. If you are testing locally you should add http://localhost:8055/auth/login/google/callback too
  6. On click Create, a modal will appear with Client ID and Client Secret. Save both somewhere to use later.

  7. Now on Directus side, you need to add the following configuration to your .env file located on root folder of your project:


AUTH_GOOGLE_CLIENT_ID="XXXX" # Replace XXXX with the Client ID from Step 6
AUTH_GOOGLE_CLIENT_SECRET="XXXX" # Replace XXXX with the Client Secret from Step 6
AUTH_GOOGLE_ALLOW_PUBLIC_REGISTRATION="true" # This allows users to be automatically created on logins. Use "false" if you want to create users manually
AUTH_GOOGLE_DEFAULT_ROLE_ID="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" # Replace this with the Directus Role ID you would want for new users. If this is not properly configured, new users will not have access to Directus
  1. Now you can see a nice functional Login with Google button on Directus login page.

Seamless SSO

While sometimes you want your users to directly have access to the Directus Application, in other cases you may need to fetch private data from Directus in your client using external providers. In this cases, it is needed a special configuration to work across domains, but is simple as:

  1. Setup an external provider. You have some examples on Supported SSO mechanisms
  2. Allow cookie to be accessible across domains. Put the following configuration on .env:
REFRESH_TOKEN_COOKIE_DOMAIN="XXXX" # Replace XXXX with the domain of your Directus instance. For example ""
  1. On your client, your login button should be something like
<a href="">Login</a>
  • Where should be the address of your Directus instance
  • While should be the address of your client application. The /login is not necessary, but helps to separate concerns
  1. On your login page, following the example should be you need to call the refresh endpoint either via REST API or via SDK in order to retrieve an access_token

    • via REST API / fetch

      await fetch('', {
      	method: 'POST',
      	credentials: 'include', // this is required in order to send the refresh token cookie
    • via SDK

      const sdk = new Directus('');
      await sdk.auth.refresh();

Testing Seamless SSO locally

The above REFRESH_TOKEN_* configuration will likely fail for local testing, as you'll likely won't be serving Directus using a valid SSL certificate which are required for "Secure" cookies. Instead, for local testing purposes (and local testing purposes only), the following configuration can be used:


Note that no REFRESH_TOKEN_COOKIE_DOMAIN value is set.

Disabling secured cookies

The configuration disable secured cookies and should only be used in local environment. Using it in production exposes your instance to CSRF attacks.