# Authentication

{% hint style="danger" %}
The client\_id  and client\_secret, which are required to invoke the Authentication API can be generated from Mogoplus console. More information available [here](https://docs.mogoplus.ai/api-management)
{% endhint %}

## How to Authenticate?

* As mentioned above, get the client id and secret from MOGOPLUS console
* Form the request as mentioned below using the above details and send
* You should receive a Bearer token in response to the request

## Login

<mark style="color:green;">`POST/`</mark>`https://auth.dev.mogoplus.ai/api/v1/oauth2/token?grant_type=client_credentials`

Invoke the API over mTLS and fetch access token from MOGOPLUS to prove the authenticity of requests

**Headers**

| Name         | Value                             |
| ------------ | --------------------------------- |
| Content-Type | application/x-www-form-urlencoded |
| Accept       | application/json                  |

**Form-data**

| Name            | Value                                                        |
| --------------- | ------------------------------------------------------------ |
| `client_id`     | {generated from user management section in Mogoplus console} |
| `client_secret` | {generated from user management section in Mogoplus console} |

**Parameters**

| Name        | Value               |
| ----------- | ------------------- |
| grant\_type | client\_credentials |

**Response**

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

```json
{
    "access_token": "eyJraWQiOiI0ZDIyZTlhMy1hNTcyMKD85Nz3kco6EHxYfTk",
    "token_type": "Bearer",
    "expires_in": 35999
}
```

{% endtab %}

{% tab title="400" %}

```json
{
    "error_description": "OAuth 2.0 Parameter: grant_type",
    "error": "unsupported_grant_type",
    "error_uri": "https://datatracker.ietf.org/doc/html/rfc6749#section-5.2"
}
```

{% endtab %}

{% tab title="401" %}

```json
{
    "error": "invalid_client"
}
```

{% 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://docs.mogoplus.ai/sandbox/api-reference/authentication.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.
