# OAuth 2.0 - Google

OAuth 2.0 with OpenID Connect with Google provides the ability to use Google as the OAuth vendor and have users login before accessing a web flow in an application.

## Configuring a Google API project

Follow [Google’s instructions](https://developers.google.com/identity/gsi/web/guides/get-google-api-clientid) to get a Google API Client ID and set the following scopes:

* Userinfo.email
* Userinfo.profile
* openid

Then in Google’s Cloud Platform, go to **Credentials** and click on the name of your OAuth 2.0 Client ID:

![](https://3333962744-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbnBffrSN2FHLC5cM89AM%2Fuploads%2Fgit-blob-cc70338a3745e3b51fbfe4a6843a0dc0237bed5c%2Fsetting-up-google-oauth-v183-0.png?alt=media)

In **Authorized Redirect URIs**, add the following Redirect URI. The `{base-domain}` can be found in **Settings**. For example, in the following screenshot, the base domain would be `app.airkit.com`.

![](https://3333962744-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbnBffrSN2FHLC5cM89AM%2Fuploads%2Fgit-blob-015c4a2c9fef0308e072379c391f1975c6ed4bc2%2Fsetting-up-google-oauth-v183-1.png?alt=media)

\[block:callout] { "type": "info", "title": "Redirect URIs", "body": "`\nhttps://{base-domain}/internal/session-gateway/v1/oauth/callback`" } \[/block]

![](https://3333962744-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbnBffrSN2FHLC5cM89AM%2Fuploads%2Fgit-blob-d1ff7844a0bb2296b73dd4f5a6b2f659c48e0055%2Fsetting-up-google-oauth-v183-2.png?alt=media)

Then, go back to **Credentials** and copy the OAuth 2.0 Client ID:

![](https://3333962744-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbnBffrSN2FHLC5cM89AM%2Fuploads%2Fgit-blob-bb5a752151c3ea2a46ae6937fc6c5e2c145c1ad1%2Fsetting-up-google-oauth-v183-3.png?alt=media)

## Configuring OAuth in the App

Access your app, go to **Settings > Global** and follow these steps:

1. From the **App Authentication Type** dropdown, select **Secure App**
2. In **Authentication Method**, select **OAuth 2.0 w/ OpenID Connect**
3. As **OAuth Vendor**, choose **Google**
4. Finally, paste your Google OAuth 2.0 Client ID and save the app

![](https://3333962744-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbnBffrSN2FHLC5cM89AM%2Fuploads%2Fgit-blob-7e370e1abee540ae48d3e5ccaeda273ab2ee2134%2Fsetting-up-google-oauth-v183-4.png?alt=media)

## Authentication Success

After setting up you OAuth authentication, go to **Connections Builder** and click on the **On Authentication Success** Event.

The “On Authentication Success” event will run when the user is authenticated. On this event, there is the `event` namespace where you can access data about the user.

```
event.attributes
```

Includes data such as:

* Email
* Picture
* Name
* Locale

```
event.nameId
```

nameId refers to the user’s email address they authenticated with.

To access this data and store it in a session variable, In the Inspector section, click on the **‘+’** icon under Actions and add two **Set Variable** actions to get the attributes of the users that signed into the app:

![](https://3333962744-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbnBffrSN2FHLC5cM89AM%2Fuploads%2Fgit-blob-9ad476cd6e5f975c92f858fb4087b7152266b7ae%2Fsetting-up-google-oauth-v183-5.png?alt=media)

Publish the app and navigate the launch trigger to check that the requested user attributes are retrieved.
