> For the complete documentation index, see [llms.txt](https://api-docs.disasteraware.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://api-docs.disasteraware.com/authentication/authorizing-requests.md).

# Authorizing Requests

In most cases, when sending requests to the DaaS services, the request includes a header that contains an authorization code. The authorization code is acquired by sending a request to DAE’s DaaS token service.

### Authorization API

| URL        | HTTP Verb | Functionality                                                            |
| ---------- | --------- | ------------------------------------------------------------------------ |
| /authorize | POST      | Login with posting credentials to get access and refresh JSON Web Tokens |

## Get accessToken and refreshToken

<mark style="color:green;">`POST`</mark> `https://api.disasteraware.com/authorize`

Login with posting credentials to get access and refresh JSON Web Tokens

#### Request Body

| Name            | Type   | Description      |
| --------------- | ------ | ---------------- |
| User credential | object | User credential. |

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

```
{
    "accessToken":"access.token.will.be.here",
    "refreshToken":"refresh.token.will.be.here"
}
```

{% endtab %}

{% tab title="401 " %}

```
Authentication failed.
```

{% endtab %}
{% endtabs %}

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

```
curl --location --request POST \
  'https://api.disasteraware.com/authorize' \
  --header 'Content-Type: application/json' \
  --data-raw '{
    "username":"your_username", 
    "password":"your_password"
  }'
```

{% endtab %}

{% tab title="Java" %}

```java
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Scanner;

class Main {

	public static void main(String[] args) throws IOException {
		URL url = new URL("https://api.disasteraware.com/authorize");
		HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
		httpConn.setRequestMethod("POST");

		httpConn.setRequestProperty("Content-Type", "application/json");

		httpConn.setDoOutput(true);
		OutputStreamWriter writer = new OutputStreamWriter(httpConn.getOutputStream());
		writer.write("{ \"username\":\"your_username\", \"password\":\"your_password\" }");
		writer.flush();
		writer.close();
		httpConn.getOutputStream().close();

		InputStream responseStream = httpConn.getResponseCode() / 100 == 2
				? httpConn.getInputStream()
				: httpConn.getErrorStream();
		Scanner s = new Scanner(responseStream).useDelimiter("\\A");
		String response = s.hasNext() ? s.next() : "";
		System.out.println(response);
	}
}

```

{% endtab %}

{% tab title="Node.js" %}

```javascript
var fetch = require('node-fetch');

fetch('https://api.disasteraware.com/authorize', {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json'
    },
    body: JSON.stringify({ "username":"your_username", "password":"your_password" })
});

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
include('vendor/rmccue/requests/library/Requests.php');
Requests::register_autoloader();
$headers = array(
    'Content-Type' => 'application/json'
);
$data = '{ "username":"your_username", "password":"your_password" }';
$response = Requests::post('https://api.disasteraware.com/authorize', $headers, $data);

```

{% endtab %}

{% tab title="Python" %}

```python
import requests

headers = {
    'Content-Type': 'application/json',
}

data = '{ "username":"your_username", "password":"your_password" }'

response = requests.post('https://api.disasteraware.com/authorize', headers=headers, data=data)

```

{% endtab %}
{% endtabs %}

{% hint style="warning" %}
Please use the provided credentials to complete this request. The response will include a JSON Web Token (JWT) that you will send with the Authorization request header in the following format:

```
{
    "Authorization": "Bearer <insert-json-web-token>"
}
```

For more information about JWT please visit [jwt.io](https://jwt.io/)
{% endhint %}
