# requestAccess

Request user approval for the current application through [EMOTIV Launcher](https://emotiv.gitbook.io/emotiv-launcher/).

When your application calls this method for the first time, EMOTIV Launcher displays a message to approve your application.\
You can call this API many times, but EMOTIV Launcher will prompt the user only once.\
If the user has already approved your application, then this API does nothing.

Almost all the methods of the API require that your application was approved in EMOTIV Launcher. These methods will return an error if your application wasn't approved.

{% hint style="success" %}
Any application that connects to Cortex must call this API to request approval from the user through [EMOTIV Launcher](https://emotiv.gitbook.io/emotiv-launcher/).
{% endhint %}

{% hint style="danger" %}
Most of the methods of the API will fail if the user didn't approve your application.
{% endhint %}

## Parameters

| Name         | Type     | Required | Description                                  |
| ------------ | -------- | -------- | -------------------------------------------- |
| clientId     | `string` | yes      | The client id of your Cortex application     |
| clientSecret | `string` | yes      | The client secret of your Cortex application |

## Result

The result is an object containing a boolean value "accessGranted" and a message.

| Name          | Type      | Description                                                                                                                              |
| ------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| accessGranted | `boolean` | <p>True, if the user has already approved your application<br>False, if the user declined your application, or didn't approve it yet</p> |
| message       | `string`  |                                                                                                                                          |

If **accessGranted** is false, then your application should ask the user to check EMOTIV Launcher and approve your application. Then you should wait for a while and call this API again.\
If **accessGranted** is true, then no action is required.

## Examples

### Application was already approved

{% tabs %}
{% tab title="Request" %}

```javascript
{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "requestAccess",
    "params": {
        "clientId": "xxx",
        "clientSecret": "xxx"
    }
}
```

{% endtab %}

{% tab title="Response" %}

```javascript
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "accessGranted":true,
        "message":"The User has granted access right to this application."
    }
}
```

{% endtab %}
{% endtabs %}

### Application is not approved yet, or declined

{% tabs %}
{% tab title="Request" %}

```javascript
{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "requestAccess",
    "params": {
        "clientId": "xxx",
        "clientSecret": "xxx"
    }
}
```

{% endtab %}

{% tab title="Response" %}

```javascript
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "accessGranted":false,
        "message":"The User has not granted access right to this application. Please use Emotiv App to proceed."
    }
}
```

{% endtab %}
{% endtabs %}


---

# 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://emotiv.gitbook.io/cortex-api/authentication/requestaccess.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.
