# Google OAuth

The API supports login and sign-up via OAuth with Google. There are four main actions supported by the API, they are as follows:

```
Login with Google
Sign Up with Google
Connect Google to an existing account
Disconnect Google from an existing account
```

There are five API Routes which apply to Oauth and help faciliate these functions:

<pre><code><strong>/customer/oauth?external_service={external_service}&#x26;authorization_type={authorization_type}
</strong>/customer/oauth_reset with external_service={external_service}

/google/login
/google/signup
/google/connect
</code></pre>

```
authorization_type = ["login" , "connect" , "signup"]
external_service = ["google"]
```

```
/customer/oauth

Get Google Redirection link for specified action
```

```
/customer/oauth_reset

Disconnect specified external service from account
```

```
/google/login
/google/signup
/google/connect

API Routes to relay Google authentication code to for authorization and either access token or 200 for connecting account.
```

## Production OAuth Flow

1. **Initiate OAuth Flow**

```
User Action: User clicks "Login with Google" in the React App
React App: Sends a request to the API to initiate OAuth /1.0/private/user/customer/oauth
API: Responds with the Google authentication URL.
```

2. **Redirect to Google for Authentication**

```
// React App: Redirects the user to the Google authentication URL.
```

3. **Google Authentication / Requires setting: company\_information\["oauth"]\["oauth\_url"]**

```
Google: Authenticates the user and redirects them to the OAuth callback in the React App (https://your-react-app.com/oauth/callback).
```

4. **Handle OAuth Code / Requires setting: company\_information\["oauth"]\["oauth\_url"]**

```
React App: Extracts the OAuth code from the URL

Consumer Secret: Store
Code from Google as arg
Self.url
```

5. **Send OAuth Code to API**

```
React App: Sends the OAuth code to the API + redirect_uri
```

6. **API Confirms Authentication**

```
API: Confirms authentication with Google and generates authentication tokens.
API Responds to React App
API: Sends authentication tokens or confirmation back to the React App.
```

7. **Store Tokens and Update Authentication State**

```
React App: Stores the tokens and updates the user's authentication state.
User: Now authenticated, continues to use the React App.
```


---

# 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://internal.developer.documentation.private.user.pingproxies.com/customer-account-management/google-oauth.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.
