# How to Log in to Omnitron Using OAuth2 (SSO)?

This guide provides a step-by-step tutorial on logging into Omnitron using OAuth2 as a Single Sign-On (SSO) method. Omnitron supports OAuth2 authentication only from the following providers:

* Google (provider: `google`)
* GitHub (provider: `github`)
* Turkcell (provider: `turkcell`)
* Azure (provider: `azure`)

OAuth2 allows users to authenticate with Omnitron using their credentials from the supported providers. This eliminates the need for separate login details for Omnitron and streamlines the authentication process.

## <mark style="color:red;">Step 1: Configure OAuth2 Provider Settings​</mark> <a href="#step-1-configure-oauth2-provider-settings" id="step-1-configure-oauth2-provider-settings"></a>

Before integrating OAuth2 with Omnitron, you must configure the necessary settings on the provider’s platform. Each provider has specific documentation on setting up OAuth2 authentication. The following credentials are typically required:

* **Client ID**: Unique identifier for your application.
* **Client Secret**: A secret key used for authentication.
* **Authorization URL**: URL to initiate the OAuth2 login flow. Format: `[auth url]?response_type=code&scope=[scope]`
* **Token URL**: URL to obtain access tokens.
* **User Info URL**: URL to fetch user details.
* **Redirect URLs**: This should be set to `{omnitron_url}/api/v1/oauth/{provider_slug}/authenticate/`
  * If you're using Azure as the provider, use the following instead:\
    `{omnitron_url}/sso/azure/callback`

Refer to the respective provider’s documentation to retrieve these values except for the Redirect URL.

## <mark style="color:red;">Step 2: Configure OAuth2 in Omnitron​</mark> <a href="#step-2-configure-oauth2-in-omnitron" id="step-2-configure-oauth2-in-omnitron"></a>

Once you have obtained the required credentials from the OAuth2 provider, you must configure them in Omnitron.

#### Navigate to SSO Settings​ <a href="#navigate-to-sso-settings" id="navigate-to-sso-settings"></a>

1. Log in to Omnitron.
2. Click on the **Settings** tab.
3. Select **SSO Settings**.\\

   <figure><img src="/files/NWnpqhtJcVxBKffeJ0n9" alt=""><figcaption></figcaption></figure>

### <mark style="color:red;">Add a New SSO Provider​</mark> <a href="#add-a-new-sso-provider" id="add-a-new-sso-provider"></a>

1. Click the **+ Add New SSO Provider** button at the top right corner.\\

   <figure><img src="/files/GnR8RWJaFXeCjCJKX0tw" alt=""><figcaption></figcaption></figure>
2. Fill in the required parameters in the form:
   * **Select Provider Type**: Select “Other” option.
   * **Name**: Enter a meaningful name for the provider.
   * **Slug**: Define a unique slug for the provider.
   * **Provider**: Enter the provider type. **It should be one of the following options:**
     1. `azure`
     2. `github`
     3. `google`
     4. `turkcell`
   * **Client ID**: Paste the Client ID obtained from the provider.
   * **Client Secret**: Paste the Client Secret obtained from the provider.
   * **Authorization URL**: Enter the provider’s authorization URL. Format: `[auth url]?response_type=code&scope=[scope]`.
   * **Token URL**: Enter the provider’s token URL.
   * **User Info URL**: Enter the provider’s user info URL.
   * **Redirect URLs**: Enter the redirect URL in the format: `{omnitron_url}/api/v1/oauth/{provider_slug}/authenticate/`
     * When using **azure** as the provider, set this to: `{omnitron_url}/sso/azure/callback`
   * **Choose File**: Drag and drop the login icon or click to upload. The image size must be 128x128 PNG.
   * **Status**: Enable or disable the provider.\\

     <figure><img src="/files/us6OpQiHFiYhFejaiB41" alt="" width="419"><figcaption></figcaption></figure>
3. Click **Save** to finalize the configuration.

#### Example OAuth2 Provider JSON Configuration​ <a href="#example-oauth2-provider-json-configuration" id="example-oauth2-provider-json-configuration"></a>

```
{
     "name": "Google",
     "slug": "google",
     "provider": "google",
     "client_id": "[masked].apps.googleusercontent.com",
     "client_secret": "[masked]", # obtained from the provider
     "authorization_url": "[auth url]?response_type=code&scope=[scope]",
     "token_url": "https://oauth2.googleapis.com/token",
     "userinfo_url": "userinfo_url",
     "redirect_url": "[omnitron_url]/api/v1/google/authenticate/"
}
```

For Google;

```
google auth url = https://accounts.google.com/o/oauth2/v2/auth
google scope = https://www.googleapis.com/auth/userinfo.email
google user info url = https://www.googleapis.com/oauth2/v2/userinfo?alt=json
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.akinon.com/tutorials/omnitron/settings/how-to-log-in-to-omnitron-using-oauth2-sso.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
