> For the complete documentation index, see [llms.txt](https://emotiv.gitbook.io/cortex-library-for-mobile/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://emotiv.gitbook.io/cortex-library-for-mobile/jsonapi/loginwithauthenticationcode.md).

# loginWithAuthenticationCode

This method is to log in into Cortex with an authentication code. You can use the method [getUserLogin](https://emotiv.gitbook.io/cortex-api/authentication/getuserlogin) to know if a user is already logged in or not.

To get an authentication code, you must call the native function CortexClient.authenticate ([Objective-C](/cortex-library-for-mobile/objective-c-api/cortexclient-class.md#authenticate), [Java](/cortex-library-for-mobile/java-api/cortexclient-class.md#authenticate))

## Parameters

| Name         | Type     | Required | Description                            |
| ------------ | -------- | -------- | -------------------------------------- |
| clientId     | `string` | yes      | The client ID of your application.     |
| clientSecret | `string` | yes      | The client secret of your application. |
| code         | `string` | yes      | An authentication code.                |

## Result <a href="#result" id="result"></a>

The result is an object with these fields:

| Name     | Type     | Description               |
| -------- | -------- | ------------------------- |
| username | `string` | The EmotivID of the user. |
| message  | `string` | ​                         |

## Example <a href="#example" id="example"></a>

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

```javascript
{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "login",
  "params": {
    "clientId": "xxx",
    "clientSecret": "yyy",
    "code": "zzz"
  }
}
```

{% endtab %}

{% tab title="Response" %}

```javascript
{
  "id": 1,
  "jsonrpc": "2.0",
  "result": {
    "message": "User jon.snow login successfully",
    "username": "jon.snow"
  }
}
```

{% endtab %}
{% endtabs %}
