Configure OAuth 2.0
You can configure OAuth 2.0 to allow users to login with their Google, GitHub, GitLab, Azure AD, or Okta account. If you use a different provider, you can use Generic OAuth or contact Support.
Configure OAuth 2.0 with Google
To configure OAuth 2.0 using Google Cloud, you must register an application and create a Google OAuth 2.0 client. You can then enable the client on your Grafana Cloud instance.
Create a Google OAuth 2.0 client
Go to the Google Cloud Platform API page.
Agree to the Terms of Service.
Create a project. Enter a project name. The Organization and Location fields should both be set to your organization’s information.
In OAuth consent screen select the External User Type. Click CREATE.
Fill out the requested information using the URL of your Grafana Cloud instance.
Accept the defaults, or customize the consent screen options.
Click + CREATE CREDENTIALS and select OAuth client ID. Enter the following, substituting your instance URL where appropriate:
Application Type: Web application
Name: Grafana
Authorized JavaScript origins:
https://<YOUR_GRAFANA_URL>
Authorized redirect URIs:
https://<YOUR_GRAFANA_URL>/login/google
Note
The URL you enter is the one for your Grafana instance home page, not your Grafana Cloud portal URL.
Click CREATE. Make a note of your OAuth 2.0 client ID and client secret.
Enable the Google client on your Grafana instance
Note
If the SSO Settings UI feature (ssoSettingsApi
) is enabled you will be redirected from the Cloud Portal to the selected instance’s administration (Administration > Authentication > Google) page.
- From the Cloud Portal, select the Advanced Auth option in the Security section.
- Click the Google option and enter your client ID and client secret. List allowed domains, for example,
grafana.com
, and click Submit.
Configure OAuth 2.0 with GitHub
To configure OAuth 2.0 using GitHub, you must register an application and create a GitHub OAuth 2.0 client. You can then enable the client on your Grafana Cloud instance.
Create a GitHub OAuth 2.0 client
- Log in to your GitHub account. In Profile > Settings > Developer settings, select OAuth Apps.
- Click Register a new application.
- Fill out the fields, using your Grafana homepage URL when appropriate.
In the Authorization callback URL field, enter the following:
https://<YOUR-GRAFANA-URL>/login/github
. - Note your client ID.
- Generate, then note, your client secret.
Enable the GitHub client on your Grafana instance
Note
If the SSO Settings UI feature (ssoSettingsApi
) is enabled you will be redirected from the Cloud Portal to the selected instance’s administration (Administration > Authentication > GitHub) page.
- From the Cloud Portal, select the Advanced Auth option in the Security section.
- Click the GitHub option and enter your client ID and client secret. List allowed GitHub organizations, for example,
Grafana
, add any Team IDs, and click Submit.
Confirm Organization Access within GitHub
If you enable allowed_organizations
, confirm the organization access request within GitHub for the Grafana instance.
You can do this in: Profile > Settings > Applications > Authorized OAuth Apps > My Grafana > Organization access or via https://github.com/settings/applications.
Configure OAuth 2.0 with GitLab
To configure OAuth 2.0 using GitLab, you must register an application and create a GitHub OAuth 2.0 client. You can then enable the client on your Grafana Cloud instance.
Create a GitLab OAuth 2.0 client
- Log in to your GitLab account and go to Profile > Preferences > Applications.
- Click Add new application.
- Fill out the fields.
In the Redirect URI field, enter the following:
https://<YOUR-GRAFANA-URL>/login/gitlab
and checkopenid
,email
,profile
in the Scopes list. - Click Save application.
- Note your Application ID and Secret.
Enable the GitLab client on your Grafana instance
Note
If the SSO Settings UI feature (ssoSettingsApi
) is enabled you will be redirected from the Cloud Portal to the selected instance’s administration (Administration > Authentication > GitLab) page.
- Go to your instance and using the left-hand menu, navigate to Administration > Authentication > GitLab.
- Switch the Enabled toggle to the right.
- Enter the required information for your OAuth 2.0 provider like the client ID (Application ID), client secret (Secret), and other settings.
- Click Save.
Configure OAuth 2.0 with Microsoft Azure AD
To enable the Azure AD OAuth 2.0 you must create a tenant or use an existing tenant and register an application with Azure AD.
Create a Azure AD OAuth 2.0 client
Log in to the Azure Portal and click View for the Manage Azure Active Directory tile. Select the Azure AD tenant you want to use if you have more than one.
Go to App registrations in the Manage section and click + New registration.
Fill in the following fields:
- Name: Choose a name for the app.
- Supported account types: Choose what kind of user accounts can be used to authorize users.
- Redirect URI Select Web, then enter the following:
https://<YOUR-GRAFANA-URL>/login/azuread
. - Click Register.
Make a note of your Application (client) ID.
Click Save.
In Certificates & secrets, click + New client secret.
Enter a name and certificate expiration.
Make a note of the Value. This is the OAuth 2.0 client secret.
Make sure that you copy the string in the Value field, rather than the one in the Secret field.
Find your API endpoints.
Click the Endpoints (globe) button. Make a note of the following endpoints:
OAuth 2.0 authorization endpoint (v2)
OAuth 2.0 token endpoint (v2)
If you don’t see the Endpoints option, it’s because you are using a personal account. You must use a tenant to create an OAuth 2.0 client.
Configure user and group permissions.
Click Manifest.
- Set
groupMembershipClaims
toApplicationGroup
. This setting will allow access to groups specified in theallowed_groups
setting in your Grafana configuration. - You must define the Application Role settings for Grafana for each user ID. If you don’t, all users will default to view mode only when accessing the Grafana instance.
You can generate random identifiers on Linux or Mac by using the
uuidgen
command in a terminal, or on Windows through PowerShell usingNew-Guid
.- Set
Assign a unique ID to each role.
Add users and their roles to the
appRoles
field of the manifest."appRoles": [ { "allowedMemberTypes": [ "User" ], "description": "Grafana admin Users", "displayName": "Grafana Admin", "id": "<SOME_UNIQUE_ID_1>", "isEnabled": true, "lang": null, "origin": "Application", "value": "Admin" }, { "allowedMemberTypes": [ "User" ], "description": "Grafana read only Users", "displayName": "Grafana Viewer", "id": "<SOME_UNIQUE_ID_2>", "isEnabled": true, "lang": null, "origin": "Application", "value": "Viewer" }, { "allowedMemberTypes": [ "User" ], "description": "Grafana Editor Users", "displayName": "Grafana Editor", "id": "<SOME_UNIQUE_ID_3>", "isEnabled": true, "lang": null, "origin": "Application", "value": "Editor" } ],
Find your application. In Azure Active Directory, click Enterprise Applications. Search for and select your application.
Click on 1. Assign users and groups. Search for a user and assign them a Grafana role. Do this for every user that will need a role other than the default View role.
Enable the Azure client on your Grafana instance
Note
If the SSO Settings UI feature (ssoSettingsApi
) is enabled you will be redirected from the Cloud Portal to the selected instance’s administration (Administration > Authentication > Azure AD) page.
- From the Grafana Cloud Portal, select the Advanced Auth option in the Security section.
- Click the Azure AD option.
- Enter your client ID, client secret, and authorization and token URLs.
Add scopes.
Enter allowed Azure Groups and allowed domains, for example,
Grafana
. For more information on Azure AD groups, refer to Configure allowed groups. - Click Submit.
Configure OAuth 2.0 with Okta
To configure OAuth 2.0 with Okta, refer to Configure Okta OIDC authentication.
Configure OAuth 2.0 with Generic OAuth
Note
SSO Settings UI is currently in public preview. Grafana Labs offers limited support, and breaking changes might occur prior to the feature being made generally available. Enable the ssoSettingsApi feature toggle in Grafana to use this feature. Contact Grafana Support to enable this feature in Grafana Cloud.
- Go to your instance and using the left-hand menu, navigate to Administration > Authentication > Generic OAuth.
- Switch the Enabled toggle to the right.
- Enter the required information for your OAuth 2.0 provider, such as the client ID, client secret, and other settings.
- Click Save.