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

# Credentials

> Get Google Credentials for Login

Follow the instructions below to generate your google credentials :

## Setting up a project in Google Cloud Console

Create a new project in [Google Cloud Console](https://console.cloud.google.com/projectcreate)

<img height="200" src="https://mintcdn.com/xyne/fT_nFAUVpQYF8W2t/images/oauth-1.png?fit=max&auto=format&n=fT_nFAUVpQYF8W2t&q=85&s=b8b8c014788d766e36b9cd2238528493" data-path="images/oauth-1.png" />

Switch to the new project you just created.

## Setting up the Oauth Consent Screen:

<Tip> For a completely new project you will need to setup the consent screen before setting the credentials.</Tip>

First step after creating the project is to setup the OAuth Consent Screen.

* For this navigate to the OAuth Consent Screen in the Sidebar of your Google Cloud Console :

<img height="200" src="https://mintcdn.com/xyne/fT_nFAUVpQYF8W2t/images/oauth-2.png?fit=max&auto=format&n=fT_nFAUVpQYF8W2t&q=85&s=a0b155c13ee7e7a00e8bee7533a5e0eb" data-path="images/oauth-2.png" />

* Under the Oauth Overview screen, click on `Get Started` button.

<img height="200" src="https://mintcdn.com/xyne/fT_nFAUVpQYF8W2t/images/gtstrtd.png?fit=max&auto=format&n=fT_nFAUVpQYF8W2t&q=85&s=c97254876c862906c3bc0f56e7b5fa7c" data-path="images/gtstrtd.png" />

* Under the `App Information` Section, fill out the details :
  * Provide a Name for the app (For ex: Xyne)
  * Provide a User Support email (For ex: [your-email@gmail.com](mailto:your-email@gmail.com))

<img height="200" src="https://mintcdn.com/xyne/fT_nFAUVpQYF8W2t/images/appinfo.png?fit=max&auto=format&n=fT_nFAUVpQYF8W2t&q=85&s=7197af24a769cbec2cd7cc2f2efd024f" data-path="images/appinfo.png" />

* Click on `NEXT`.

* Under `Audience` section select `Internal` :

<img height="200" src="https://mintcdn.com/xyne/fT_nFAUVpQYF8W2t/images/oauth-int.png?fit=max&auto=format&n=fT_nFAUVpQYF8W2t&q=85&s=fd9bc03244d0e89074b3937a757b417d" data-path="images/oauth-int.png" />

<Tip> If you're using personal email, you can choose `External`.</Tip>

* Click on `NEXT`.

* Under `Contact Information` give the developer email. (For ex: [your-contact@gmail.com](mailto:your-contact@gmail.com))

<img height="200" src="https://mintcdn.com/xyne/fT_nFAUVpQYF8W2t/images/oauth-email.png?fit=max&auto=format&n=fT_nFAUVpQYF8W2t&q=85&s=a33bbd641109201bc03eecebe61d2a71" data-path="images/oauth-email.png" />

* Click on `NEXT`.

* Under the `Finish` section click on the checkbox to accept Google's User Data Policy.

<img height="200" src="https://mintcdn.com/xyne/fT_nFAUVpQYF8W2t/images/oauth-acpt-dtp.png?fit=max&auto=format&n=fT_nFAUVpQYF8W2t&q=85&s=8c95816eaa3402b5ef3179e5eacfcbdc" data-path="images/oauth-acpt-dtp.png" />

* Click on `CONTINUE`.

* Click on `CREATE`.

<Tip>If you had previously chosen `External` in your `Audience` section, you can now navigate to `Audience` section again  in the side menu and add your allowed external users in the `Test Users` section. </Tip>

#### Setting Scopes :

* Now navigate to the `Data Access` section on the left-side menu.

<img height="200" src="https://mintcdn.com/xyne/fT_nFAUVpQYF8W2t/images/dtacc.png?fit=max&auto=format&n=fT_nFAUVpQYF8W2t&q=85&s=6fae79eb6ffb54cdc38d6adc65bcac4b" data-path="images/dtacc.png" />

* Under the `Scopes` section you'll see the `Add or Remove Scopes` button. Click on that:

<img height="200" src="https://mintcdn.com/xyne/fT_nFAUVpQYF8W2t/images/oauth-scopes.png?fit=max&auto=format&n=fT_nFAUVpQYF8W2t&q=85&s=dc33cb7530c16fd414727fc1043ae49d" data-path="images/oauth-scopes.png" />

<Tip> If you're going for OAuth Authentication you can set all the scopes using this part of the [OAuth Authentication Guide](https://docs.xynehq.com/authentication/oauth#adding-the-scopes-for-the-enabled-apis).
If not you can add the scopes mentioned below. </Tip>

* For now in the scope section only add `/auth/userinfo.email`,`/auth/userinfo.profile` and `openid`, leave out the rest of it.

<img height="200" src="https://mintcdn.com/xyne/fT_nFAUVpQYF8W2t/images/initial-scope.png?fit=max&auto=format&n=fT_nFAUVpQYF8W2t&q=85&s=5aed57e66c31832ccca3fe1a15904917" data-path="images/initial-scope.png" />

* Click on `Save`.

This concludes the setting-up of your OAuth Consent Screen

## Setting up the OAuth Credentials

* Now, under `Clients` section in the menu on the sidebar,

<img height="200" src="https://mintcdn.com/xyne/fT_nFAUVpQYF8W2t/images/clients.png?fit=max&auto=format&n=fT_nFAUVpQYF8W2t&q=85&s=62230a0e3a399cf81cc6048f62a14344" data-path="images/clients.png" />

* Click on `+CREATE CLIENT`,

* Under that you will see `Create OAuth client ID` option.

<img height="200" src="https://mintcdn.com/xyne/fT_nFAUVpQYF8W2t/images/cocid.png?fit=max&auto=format&n=fT_nFAUVpQYF8W2t&q=85&s=356b4d271a3a465720f7bc72c5a9b396" data-path="images/cocid.png" />

* Add the type as `Web Application`, and give it a name (For ex: Xyne)

<img height="200" src="https://mintcdn.com/xyne/fT_nFAUVpQYF8W2t/images/oauth-6.png?fit=max&auto=format&n=fT_nFAUVpQYF8W2t&q=85&s=8c8805d56a51d553bf93e894d459a4ab" data-path="images/oauth-6.png" />

* Add Authorized JavaScript origins as:
  * `http://localhost:3001` for local or replace with `http://<YOUR_AWS_EC2_IPv4_DNS>` for production.

* Add Authorized redirect URIs as:
  * `http://localhost:3001/v1/auth/callback` for local setup or `https://<YOUR_AWS_EC2_IPv4_DNS>/v1/auth/callback` for production.
  * `http://localhost:3001/oauth/callback` for local setup or `https://<YOUR_AWS_EC2_IPv4_DNS>/oauth/callback` for production.

<Note> Use `http://localhost:3000` as authorized Javascript Origins. Use `http://localhost:3000/v1/auth/callback` and `http://localhost:3000/oauth/callback` when using dev-mode.</Note>

Click `CREATE` and make sure to save the Client ID and Client Secret for putting it in the [`.env` of the application](https://docs.xynehq.com/quickstart#setting-the-environment-variables)

<Tip> With this you will now be able to successfully login to Xyne with your google account.</Tip>

You can use the following Guides to add your scopes for your project:

<CardGroup>
  <Card title="Oauth Authentication" icon="lock" href="/authentication/oauth">
    Authenticate with Oauth Account.
  </Card>

  <Card title="Service Account Authentication" icon="gear-code" href="/authentication/service-accounts">
    Authenticate with Service Account.
  </Card>
</CardGroup>
