> For the complete documentation index, see [llms.txt](https://developers.innerspace.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.innerspace.io/deprecated-api-2025-05-26/authentication-v1.5-deprecated.md).

# Authentication (v1.5 - deprecated)

### Summary

API access is available to users via their JWT bearer token, or can be made available to a backend system via an M2M token issued by InnerSpace.

### Developer Access

Contact **<sales@innerspace.io>** for developer access.  They will provide you with a ClientID and ClientSecret.

They will need to know the usage of the credentials - whether it is needed for a backend service, a native application, a single-page web app or regular web app.

### Backend Services

Backend services should use the `/oauth/token` endpoint below, which behaves as documented in the [Auth0 machine-to-machine (m2m) Client Credentials Flow](https://auth0.com/docs/get-started/authentication-and-authorization-flow/client-credentials-flow).

### Examples

{% code title="Python Example" overflow="wrap" lineNumbers="true" %}

```python
# retrieve auth token (cache for reuse)
auth_data = {
    "client_id": 'Your Client ID',
    "client_secret": 'Your Client Secret' }
# auth credentials should be sent as form URL encoded
response = requests.post(url="https://api.innerspace.io/api/rest/oauth/token", json=auth_data, headers={'Content-Type': 'application/json'}
)
access_token = response.json()['oauth_token']['access_token']
# call API using auth token
url_path = 'https://api.innerspace.io'
authorization = f'Bearer {access_token}'
sample_graphql = {
    "operationName": "sample_graphql",
    "variables": {},
    "query": "query sample_graphql { BUILDING_INSIGHTS(where: {DATE_PARTITION: {_eq: 20250501}, BUILDING_ID: {_eq: 71}, GRANULARITY: {_eq: \"PT1H\"}, GROUP_ID: {_eq: \"all-e707b3a8-0732-49ae-9156-13ff1138540e\"}, SITE_ID: {_eq: 900000222}}, order_by: {DATE_TIME_START: desc}) { BUILDING_ID\n DATE_TIME_START\n OCCUPANCY_MEAN\n GRANULARITY\n GROUP_ID\n SITE_ID\n }\n }"
}
response = requests.post(url_path, json=sample_graphql, headers={'Accept': 'application/json', 'Authorization': authorization})
```

{% endcode %}

{% code title="CURL Example" %}

```bash
# Retrieving token
curl --request POST \
     --url https://api.innerspace.io/api/rest/oauth/token \
     --header 'Content-Type: application/x-www-form-urlencoded' \
     --data 'client_id=Your%20Client%20ID&client_secret=Your%20Client%20Secret'

# Calling API
curl --request POST \
  --url https://api.innerspace.io \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer <Access Token>' \
  --data '{"operationName":"sample_graphql","variables":{},"query":"query sample_graphql { BUILDING_INSIGHTS(where: {DATE_PARTITION: {_eq: 20250501}, BUILDING_ID: {_eq: 71}, GRANULARITY: {_eq: \"PT1H\"}, GROUP_ID: {_eq: \"all-e707b3a8-0732-49ae-9156-13ff1138540e\"}, SITE_ID: {_eq: 900000222}}, order_by: {DATE_TIME_START: desc}) { BUILDING_ID\n DATE_TIME_START\n OCCUPANCY_MEAN\n GRANULARITY\n GROUP_ID\n SITE_ID\n }\n }"'
```

{% endcode %}

{% code title="Python GraphQL" lineNumbers="true" %}

```python
# retrieve auth token (cache for reuse)
auth_data = {
    "client_id": 'Your Client ID',
    "client_secret": 'Your Client Secret' }
# auth credentials should be sent as form URL encoded
response = requests.post(url="https://api.innerspace.io/api/rest/oauth/token", json=auth_data, headers={'Content-Type': 'application/json'}
)
access_token = response.json()['oauth_token']['access_token']
# call API using auth token
url_path = 'https://api.innerspace.io'
authorization = f'Bearer {access_token}'
sample_graphql = {
    "operationName": "sample_graphql",
    "variables": {},
    "query": "query sample_graphql { BUILDING_INSIGHTS(where: {DATE_PARTITION: {_eq: 20250501}, BUILDING_ID: {_eq: 71}, GRANULARITY: {_eq: \"PT1H\"}, GROUP_ID: {_eq: \"all-e707b3a8-0732-49ae-9156-13ff1138540e\"}, SITE_ID: {_eq: 900000222}}, order_by: {DATE_TIME_START: desc}) { BUILDING_ID\n DATE_TIME_START\n OCCUPANCY_MEAN\n GRANULARITY\n GROUP_ID\n SITE_ID\n }\n }"
}
response = requests.post(url_path, json=sample_graphql, headers={'Accept': 'application/json', 'Authorization': authorization})
```

{% endcode %}
