# Google OAuth2

## Create new Credentials in the Google Cloud Console

To set up Google authentication for UI Bakery, follow these steps:

1. Go to [Google Cloud Console](https://console.cloud.google.com/) and create new credentials for **OAuth Client ID;**
2. Select **Web Application** as the Application type;
3. Optionally, add your instance address in **Authorized JavaScript Origins'**
4. Add **Authorized Redirect URIs** with the value `https://YOUR_INSTANCE/auth/oauth2/callback`
5. Click Save and copy **Client ID.**

## Update UI Bakery environment variables

For Google authorization, you have two options for configuration.

### **Option 1 (Recommended):**

Use a single variable configuration:

```
UI_BAKERY_GOOGLE_CLIENT_ID=<your-client-id>
```

### **Option 2 (Classic OAuth Integration):**

Alternatively, you can set up Google SSO as a classic OAuth integration with the following variables:

```
UI_BAKERY_OAUTH_CLIENT_ID=<your-client-id>
UI_BAKERY_OAUTH_CLIENT_SECRET=<your-client-secret>
UI_BAKERY_OAUTH_SCOPE=profile email
UI_BAKERY_OAUTH_AUTH_URL=https://accounts.google.com/o/oauth2/v2/auth
UI_BAKERY_OAUTH_TOKEN_URL=https://oauth2.googleapis.com/token
UI_BAKERY_OAUTH_USERINFO_URL=https://openidconnect.googleapis.com/v1/userinfo
UI_BAKERY_BRANDING_AUTH_SSO_BTN_TEXT=Login with Google
```

{% hint style="info" %}
Please note that syncing roles with Google OAuth is not supported. To achieve this, you'll need to set up Google SAML App for role synchronization.
{% endhint %}


---

# 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.uibakery.io/on-premise/sso/openid/google-oauth2.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.
