> ## Documentation Index
> Fetch the complete documentation index at: https://docs.refold.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Setup

> Connect to your Google Admin app for OAuth.

To setup your Google Admin app in Refold for OAuth, you will need the following credentials from your [Google Cloud Console dashboard](https://console.cloud.google.com/projectselector2/home/dashboard?supportedpurview=project):

* Client ID
* Client Secret
* Scopes

### Pre-requisites

1. Google Cloud Console account. You can create one [here](https://cloud.google.com/cloud-console/).

### Required Settings

* **Mandatory Scopes**

1. [https://www.googleapis.com/auth/userinfo.email](https://www.googleapis.com/auth/userinfo.email)
2. [https://www.googleapis.com/auth/admin.reports.audit.readonly](https://www.googleapis.com/auth/admin.reports.audit.readonly)

<Info>If you haven't already created a project in Google Cloud Console, you'd need to create one.</Info>

### Creating an app in Google Admin

To create a Google Admin app and acquire the above mentioned credentials, please follow the steps mentioned below:

1. Log in to your [Google Cloud Console dashboard](https://console.cloud.google.com/projectselector2/home/dashboard?supportedpurview=project).
2. Click on the `Create Project` button in the top right.

<img height="200" src="https://mintcdn.com/cobalt-55/yYFE4rj1UK1LIP4D/images/Googledrive/drive_navigation.png?fit=max&auto=format&n=yYFE4rj1UK1LIP4D&q=85&s=58a84d4da5c532d12d90a65259605258" alt="Navigation for App setup" data-path="images/Googledrive/drive_navigation.png" />

3. Enter the **Project Name** for your application, select **Organization** and **Location**.
4. In the [Google Cloud Console dashboard](https://console.cloud.google.com/projectselector2/home/dashboard?supportedpurview=project), navigate to `APIs and services` > `Credentials` in the left side menu.

<Warning>
  Ensure that the correct app is selected by checking the name of the app in the dropdown in the top navigation bar.
</Warning>

<img height="200" src="https://mintcdn.com/cobalt-55/yYFE4rj1UK1LIP4D/images/Googleadmin/admin_config.png?fit=max&auto=format&n=yYFE4rj1UK1LIP4D&q=85&s=cf20d1672816f35466f63fdc74372e59" alt="Setting up Google Admin app" data-path="images/Googleadmin/admin_config.png" />

5. Go to your [`Apps catalog`](https://app.gocobalt.io/apps) in **Refold** > Search for `Google Admin` > `Settings` > `Use your credentials` > `Callback Url` > Copy it.
6. Click on `+ Create Credentials` button in the top in the Cloud Console app and select `OAuth client ID`.

<Info>
  **Note**: You will need to configure Google's [consent screen](https://console.cloud.google.com/apis/credentials/consent) for access to Client ID and Client Secret if not done previously.
</Info>

7. Select `Web application` from the **Application type** dropdown > scroll to `Authorized redirect URIs` section > Click `+ Add URI` button > Paste the Callback Url > Click `Create` button in the bottom.
8. Navigate to `OAuth consent screen` in the left menu under `APIs and services` > Click on the `Edit App` button > Scroll down > Click `Save and Continue` in the **OAuth consent screen** section > Click `Add or Remove Scopes` button in the **Scopes** section.
9. Enter the **mandatory scopes** under `Manually add scopes` > Click on `Add To Table` > Click on `Update` > Click on `Save and Continue` at the bottom of the page.

<img height="200" src="https://mintcdn.com/cobalt-55/yYFE4rj1UK1LIP4D/images/Googleadmin/admin_setscopes.png?fit=max&auto=format&n=yYFE4rj1UK1LIP4D&q=85&s=336bde48dfd71d5e4beee847711e2fde" alt="Scopes Selection in Google Admin App" data-path="images/Googleadmin/admin_setscopes.png" />

10. Go to `Enabled APIs and services` in the left menu under **APIs and services** > Click on `+ Enable APIs and Services` > Search for `Admin SDK API` > Click on `Enable`.

<img height="200" src="https://mintcdn.com/cobalt-55/yYFE4rj1UK1LIP4D/images/Googleadmin/admin_api.png?fit=max&auto=format&n=yYFE4rj1UK1LIP4D&q=85&s=f07e5eb3356ceadc0e8c9c5102267dfb" alt="Enable API" data-path="images/Googleadmin/admin_api.png" />

11. Navigate to `Credentials` in the left menu under `APIs and services` and select the Web Client under `OAuth 2.0 Client IDs`. Copy the **Client ID** and **Client Secret** under `Additional information` section.

<img height="200" src="https://mintcdn.com/cobalt-55/yYFE4rj1UK1LIP4D/images/Googleadmin/admin_credentials.png?fit=max&auto=format&n=yYFE4rj1UK1LIP4D&q=85&s=770b35efe8f5df9239ea5bca9ded96ad" alt="Getting Credentials" data-path="images/Googleadmin/admin_credentials.png" />

#### Configuring credentials in Refold

App settings page lets you configure the authentication settings for an `OAuth2` based application. For your customers to provide you authorization to access their data,
they would first need to install your application. This page lets you set up your application credentials.

<img height="200" src="https://mintcdn.com/cobalt-55/yYFE4rj1UK1LIP4D/images/Googleadmin/admin_cobalt.png?fit=max&auto=format&n=yYFE4rj1UK1LIP4D&q=85&s=ace4a47b368e6a6e67d7bb4bc9bdd88f" alt="Setting up application client credentials" data-path="images/Googleadmin/admin_cobalt.png" />

Provide the acquired Client ID and Client Secret under Settings of the app and save it.

### Configuring Scopes

Refold lets you configure what permissions to ask from your users while they install your application. The scopes can be added or removed from the App settings page, under `Permissions & Scopes`
section.

For some applications Refold sets **mandatory scopes** which cannot be removed. Additional scopes can be selected from the drop down. Refold also has the provision to add any
custom scopes supported by the respective platform.

<img height="200" src="https://mintcdn.com/cobalt-55/yYFE4rj1UK1LIP4D/images/Googleadmin/admin_scopes.png?fit=max&auto=format&n=yYFE4rj1UK1LIP4D&q=85&s=bd96735212ac1f60c029db3b2203b8c6" alt="OAuth Scopes" data-path="images/Googleadmin/admin_scopes.png" />

Once the scopes has been added to the project in Refold, go to your [Google Cloud Console dashboard](https://console.cloud.google.com/projectselector2/home/dashboard?supportedpurview=project) and update the scopes as added on Refold.

Navigate to  `Cloud Console dashboard` > Select the **Project** created for Refold > Follow the steps 8 and 9 mentioned [above](https://docs.gocobalt.io/resources/integration-providers/google_admin#creating-an-app-in-google-admin) for adding scopes.

<Warning>
  If you are facing scopes missing or invalid scope error. Make sure you are not passing any custom scope not supported by the platform. And, the scopes selected here are
  identical to the ones selected in the platform.
</Warning>

## App Review for Google Admin

Projects configured with a publishing status of `In production` are available to any user with a Google Account. Projects configured with a publishing status of In production should complete the verification process, including defining scopes actively requested by your project's OAuth clients, if it meets one or more of the OAuth verification criteria.

#### To submit app for review

* In the Project, go to `OAuth consent screen` in the left menu under **APIs and services** > Choose the App type as `External` and click on `Publish App` button.
* Click on `Prepare for Verification` and provide the required information.
* You will be required to submit justification for the scopes requested and a demo video on YouTube which shows the scopes being used.

<img height="200" src="https://mintcdn.com/cobalt-55/yYFE4rj1UK1LIP4D/images/Googleadmin/google_review.png?fit=max&auto=format&n=yYFE4rj1UK1LIP4D&q=85&s=6b867f5547e5271864e0453bef433652" alt="App Review" data-path="images/Googleadmin/google_review.png" />

<Tip>
  Learn more about publishing apps in Google Cloud Console [here](https://support.google.com/cloud/answer/10311615?).
</Tip>

## Actions and triggers

Once the above setup is completed, you can create orchestrations of your use-cases using Google Admin actions and triggers. Following are the set of Google Admin actions and triggers
supported by Refold.

<Tabs>
  <Tab title="Actions">
    <AccordionGroup>
      <Accordion title="User Activity">
        1. **Get User Activities For A Particular Application** - Get User Activities For A Particular Application in Google Admin.
      </Accordion>

      <Accordion title="User">
        2. **Create User** - Create a new user in Google Admin.
        3. **Delete User** - Delete a user by ID in Google Admin.
      </Accordion>

      <Accordion title="Others">
        4. **HTTP Request** - Make HTTP API calls to any Google Admin documented REST APIs.
      </Accordion>
    </AccordionGroup>
  </Tab>

  <Tab title="Triggers">
    There are no triggers in this application.
  </Tab>
</Tabs>
