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

# Connect

> Advanced integration workflow with consent-based access to user data via Open APIs

This requires a more hands-on approach from the channel partner's development team. It is suitable for partners who desire a more integrated solution with consent-based access to user data via open APIs.

![Quicko Web Integration Connect Workflow](https://mintcdn.com/company-quicko-8c502003/WQlNPxL-997jalUs/projects/connect/assets/integrations/web/connect.png?fit=max\&auto=format\&n=WQlNPxL-997jalUs\&q=85\&s=29526f120d55c57453677d2e8dad6086)

## Open API Access

> [card] User Consent
>
> In the context of integrating with open APIs, it is crucial to understand that obtaining an access token, which includes user consent, is a fundamental requirement. This process ensures that all interactions with the API are secure and authorized by the user. It's important to note that the workflow for integrating these APIs into a web environment is slightly different compared to mobile integration. This document will provide a clear guide on how to effectively implement the workflow for web integration while adhering to the necessary security protocols and user consent guidelines.

## Workflow Overview

**1. Initiate OAuth Flow**

The Host app initiates the OAuth flow by redirecting the user to Quicko OAuth with a properly constructed URL including an options object that is base64 encoded.

**2. User Consent**

The user grants consent on Quicko's OAuth app for data sharing.

**3. Exchange Request Token**

Upon successful consent, Quicko redirects back to the Host app with a `request_token`. The Host app exchanges this token for an access token.

**4. Data Access**

With the access token, the Host app can now access the user's Quicko data.

**5. Income Tax Web App Redirection**

Finally, the Host redirects the user to Quicko's Income Tax Web App to proceed with their tax-related activities.

## Step-by-Step Integration

### 1. Redirect to Quicko OAuth

Construct a redirect URL to Quicko's OAuth endpoint. Include your `api_key` and the `redirect` (the URL to which Quicko will send the user after authorization) and an `options` query parameter, which is a base64-encoded JSON object containing user details and theme preferences.

#### Options Object

Here is the JSON structure of the options object:

```json theme={null}
{
    "user": {
        "email": "[email protected]",
        "mobile": {
            "isd": "91",
            "number": "XXXXXXXXXX"
        }
    },
    "theme": {
        "mode": "dark",
        "seed": "#2962FF"
    },
    "intent": "SAVE" | "PAY" | "FILE" | "TRACK"
}
```

> [card] Encoding
>
> Encode this JSON object in base64 and append it as a query parameter to the OAuth URL.

For referral attribution, you can also pass a `ref` query parameter containing the unique value you created on Cliq. See [Affiliates](https://developer.quicko.com/projects/connect/guides/affiliates/index.md) for signup and setup instructions. If you pass `ref` to OAuth, you do not need to pass it again when redirecting the user to the Income Tax App.

**Sample URL:**

```text theme={null}
https://oauth.quicko.com/?api_key={{your_api_key}}&redirect={{base64_encoded_host_redirect}}&ref={{YOUR_REF}}&options=eyJ1c2VyIjp7ImVtYWlsIjoidXNlckBtYWlsLmNvbSIsIm1vYmlsZSI6eyJpc2QiOiI5MSIsIm51bWJlciI6IlhYWFhYWFhYWFgifX0sInRoZW1lIjp7Im1vZGUiOiJkYXJrIiwic2VlZCI6IiMyOTYyRkYifSwiaW50ZW50IjoiRklMRSJ9
```

### 2. User Consent

When the user is redirected to Quicko's OAuth endpoint, they will be presented with the consent screen. Upon granting consent, Quicko will redirect the user back to your `redirect`.

### 3. Handle the Redirect

Upon user consent, Quicko redirects the user to your `redirect` with a `request_token`. If the user denies consent, they will be redirected back with a query parameter `status` set to `cancelled`.

For example, if the host's `redirect` is `host-app.com/incoming`, the user will be redirected to:

> [card] Consent Denied
>
> ```text theme={null}
> https://host-app.com/incoming?status=cancelled
> ```

> [card] Consent Acquired
>
> ```text theme={null}
> https://host-app.com/incoming?status=success&request_token={{token}}
> ```

#### Handling Denial of Consent

> [card] User Denies Consent
>
> If a user denies consent, handle the redirection with the `status` parameter appropriately in your application flow, typically by presenting an appropriate message to the user or offering the option to retry the authorization process.

### 4. Exchange Request Token

Your server should exchange the `request_token` for an access token by making a server-side request to Quicko's token exchange endpoint. Store this access token securely on your server for subsequent requests to Quicko's APIs.

> [card] OAuth Authorize API
>
> You can use the OAuth Authorize API for this exchange.

### 5. Redirect to Income Tax Web App

With the access token, query the user's data as needed. Then, to continue their tax journey, redirect the user to Quicko's Income Tax Web App.

**URL:** `https://it.quicko.com`

If you passed `ref` to OAuth in step 1, no additional `ref` query parameter is needed here. Otherwise, for referral attribution, include your Cliq `ref` value on this redirect:

```text theme={null}
https://it.quicko.com?ref={{YOUR_REF}}
```

## Recommendations

> [accordion] Secure Storage
>
> Always ensure the `access_token` is stored securely on your server. Never expose it in client-side code or public repositories.

> [accordion] Event Handling
>
> Regularly listen to event postbacks from Quicko's services to keep track of the user's journey and take appropriate actions.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.