---
title: Authentication
slug: authentication
docTags: 
createdAt: 2022-06-11T13:41:15.000Z
---

## Header

To authenticate, add an Authorization header to your API request that contains an API Key (see below).

We are using [Basic authentication](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Authorization#basic_authentication) so you need to construct the credentials first combining any string as first value and the password (your api key) with a colon. Then encode the string [base64](https://developer.mozilla.org/en-US/docs/Glossary/Base64).


API Key
-------

An API Key can be generated in your Trust account.&#x20;



## Example

```csharp
 private void GetAuthenticationHeader(HttpClient client)
{
    var byteArray = Encoding.ASCII.GetBytes("dummy" + ":" + _apiKey);
    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));
}
```

```javascript
let  http = require('http');
const host = "https://api.usetrust.app/v1/testimonial/all/c2cd39b7-239c-4455-a4e6-aa5879a1e858";

let request = http.request({'hostname': host',
                            'auth': 'dummy:' + apiKey
                           }, 
                           function (response) {
                             console.log('STATUS: ' + response.statusCode);
                             console.log('HEADERS: ' + JSON.stringify(response.headers));
                             response.setEncoding('utf8');
                             response.on('data', function (chunk) {
                               console.log('BODY: ' + chunk);
                             });
                           });
request.end();
```

```javascript
let request = require('request');
const username = "dummy";
const password = apiKey;
const auth = "Basic " + new Buffer(username + ":" + password).toString("base64");
const url = "https://api.usetrust.app/v1/testimonial/all/c2cd39b7-239c-4455-a4e6-aa5879a1e858";

request.get( {
    url : url,
    headers : {
        "Authorization" : auth
    }
  }, function(error, response, body) {
      console.log('body : ', body);
  } );
```

