# Authentication

CloudIO REST API supports authentication using username and password, or with a key and secret, or with OAuth 2.0, an open protocol that allows secure API authorization.

## JSON

Both the request and response payloads are in JavaScript Object Notation (JSON) format with UTF-8 encoding. Date-time information is in ISO 8601 format. For example, 2012-08-30T02:56:20.000-0700

## Understanding authentication

CloudIO uses the OAuth protocol to allow the users of the application to securely access data without having to reveal their username and password credentials. For a simple integration, CloudIO supports username and password, or a key and secret option. Before making REST API calls, the client application must authenticate the application user using one of these methods. After successfully authenticating the client application user with CloudIO, the client receives a *sessionId* token which are used to make authenticated REST API calls.

To generate a token and secret key, sign into the CloudIO Platform and navigate to /api/keys though the browser.

The *sessionId* attribute in the response is stored by the client application and is passed in all the subsequent authenticated REST API calls. The *sessionId* expires if the client application is inactive for the number of minutes exceeding those specified in the *sessionTimeout* attribute. You can set the *sessionTimeout* for the REST client user using default session timeout CoudIO profile at the user level.

{% hint style="success" %}
**Note:** The client application will have access to the datasources that are assigned to the roles accessible to the connected user.
{% endhint %}

## Checking the validity of an existing session

The *sessionId* passed in every REST API request must be valid and active. You can use *validateSession* API to validate a given sessionId before making the actual REST API request.


---

# 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.cloudio.io/creating-datasources/working-with-datasources/accessing-data-sources-using-rest-api/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.
