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

# <access-service>/api/oauth/token

## URL structure&#x20;

```text theme={null}
https://access-service.xy-company.com/api/oauth/token
```

## Supported methods and overview&#x20;

* `POST` - used to obtain for an [access token](/3.2/admin-platform/configuring-client-applications.md#grant-types) (and optional refresh token) representing a Covata user (typically within an [organization](/3.2/admin-org/administering-users-within-an-organisation.md)) using either the *authorization code* or *password* OAuth 2.0 grant types.

## Detailed description&#x20;

This API endpoint serves a number of purposes:

* Completes authorization to obtain an access token (and optionally a refresh token) when using the OAuth 2.0 [authorization code](/3.2/api/authentication-and-authorisation.md#using-the-authorization-code-grant-type-step-3) grant type.
* Initiates a request for an access token (and optionally a refresh token) using the OAuth 2.0 [password](/3.2/api/authentication-and-authorisation.md#using-the-password-grant-type) grant type grant type.

## Required headers&#x20;

The request's header requires [HTTP Basic authentication](http://tools.ietf.org/html/rfc1945#section-11.1), whose value is the string value of your application's client ID and client secret (separated by a colon) and encoded with [Base64](https://tools.ietf.org/html/rfc4648).

> [!NOTE]
>
> The client ID and client secret values constitute your application's client credentials, which would have been generated when your application was [registered](/3.2/api/authentication-and-authorisation.md#registering-your-application-on-the-platform) on the Covata Platform. Also see [Configuring client applications](/3.2/admin-platform/configuring-client-applications.md) in the Safe Share Administrator's Guide for more information.

For example, encoding:

* `exampleClientApplication:exampleClientApplicationSecret` \

  with Base64 results in the value:
* `ZXhhbXBsZUNsaWVudEFwcGxpY2F0aW9uOmV4YW1wbGVDbGllbnRBcHBsaWNhdGlvblNlY3JldA==`

Therefore, the HTTP Basic authentication header would be:

* `Authentication: Basic ZXhhbXBsZUNsaWVudEFwcGxpY2F0aW9uOmV4YW1wbGVDbGllbnRBcHBsaWNhdGlvblNlY3JldA==`

The request also requires form URL-encoded data in the body:

* `Content-Type: application/x-www-form-urlencoded`

## Required parameters&#x20;

The following required parameter must be sent in the body of the request (as form URL-encoded data):

* **grant\_type** - The grant type used in the authentication and authorization request/s to the Covata Platform. Specify a value of:

  * `password` for the password grant type \

    *or*
  * `authorization_code` for the authorization code grant type.

## Grant type-specific parameters&#x20;

In addition to the [required parameters](/3.2/api/access-service-api-oauth-token.md#access-service-api-oauth-token-required-parameters) above, some of the following parameters are *also required* based on the grant type used and should be included in the body of the request (as form URL-encoded data):

* **code** ( *Required when using the authorization code grant type* ) - The authorization code itself, which is retrieved in the response from the Covata Platform (i.e. following an initial request to [\<access-service>/api/oauth/authorize](/3.2/api/access-service-api-oauth-authorize.md) to initiate the process for obtaining an access token).
* **redirect\_uri** ( *Required when using the authorization code grant type* ) - The redirect URI that was submitted in the initial request to [\<access-service>/api/oauth/authorize](/3.2/api/access-service-api-oauth-authorize.md) to retrieve an access token. The value specified here is only used validate that it matches the **redirect\_uri** value specified in this initial request.
* **username** ( *Required when using the password grant type* ) - The email address of a Covata user's credentials (acquired through your application).
* **password** ( *Required when using the password grant type* ) - The password of a Covata user's credentials (acquired through your application).

  **Example (request parameters - using the password grant type):**

  ```text theme={null}
  grant_type=password&username=alex.originator%40covata.com&password=password1
  ```

## Returns&#x20;

A JSON-formatted response containing the following members:

* **access\_token** - The access token itself, as a [JSON Web Token (JWT)](https://jwt.io/introduction/) value. The resources (i.e. API endpoints) of the Covata Platform that this access token grants permission to are based on the Covata user whose credentials were used for authentication, that user's [roles](/3.2/admin-org/administering-users-within-an-organisation.md#an-organisation-users-roles) (explained in more detail in the [Organization Administrator's Guide](/3.2/admin-org.md)) and if applicable to the API endpoint, the user's:

  * membership of organizations and
  * ownership or collaborator status on files or folders.
* **token\_type** - The brief description for the type of token (above) - i.e. usually `bearer`.
* **refresh\_token** - The refresh token itself, as a universally unique identifier (UUID) value. This value will not be present if the configuration of your client application on the Covata Platform does not permit refresh tokens to be issued. See [Registering your application on the Covata Platform](/3.2/api/authentication-and-authorisation.md#registering-your-application-on-the-platform) for more information.
* **jti** - The UUID value for the JWT access token issued in this response. This value is a unique ID for the JWT issued in this response and is also known as a JWT ID.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SSU5GT19VUERBVEUiLCJTQ09QRV9BQ0xfQURNSU4iLCJTQ09QRV9DT05UQUNUU19ERUxFVEUiLCJTQ09QRV9BUFBfQVBQUk9WQUxfUkVWT0tFIiwiU0NPUEVfUFJJTlQiLCJTQ09QRV9VU0VSSU5GT19HRVRfTk9USUZZX1BSRUYiLCJTQ09QRV9WSUVXX09USEVSIiwiU0NPUEVfUkVOQU1FIiwiU0NPUEVfQ09OVEFDVFNfQ1JFQVRFIiwiU0NPUEVfREVMRVRFX09USEVSIiwiU0NPUEVfQVBJX09BVVRIX0FDQ0VTUyIsIlNDT1BFX0RPV05MT0FEIiwiU0NPUEVfQVBQX0FQUFJPVkFMX0xJU1QiLCJTQ09QRV9VU0VSSU5GT19HRVRTRUxGIiwiU0NPUEVfQ09QWSJdfQ.XMEGyBnYEfy8dAPnJhchYlSJGreBRYGN1KbSF4DZoM6aegIPuSd-hES-nDH56ErrY-xLoMnrWYNeBKEE-Z1eJ6Y2qTnUexebWe7FMcqlVDRSKKQHw2pvcchRMuET3DibxwMZv-JwYcgb1npOWQL5ESRD38k-4kKoVfLfmStkm3kGuPsOr7db2kj6mQF8eMuvXjplzUMU2o42YdgBxLQ0jPcN-FM9yGxFJhWqZ_u6J45Fjlcc1SNYtgQZbwdd4IhfuBtLXqfeEVnNA7gRuNBwsEgBqx3G-i1xtu7ibt8i382JBO0gNmkxxPEK-E5tys-0EwOEv1i42_EYX7nBKd5i5A",
      "token_type": "bearer",
      "refresh_token": "75605643-a194-4bfc-a379-0d0154ab9783",
      "jti": "f1cd84ea-c6e8-4788-879b-13d34d44d526"
  }
  ```


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