Add Authentication to code example

Hello,

i’ve setup the api documentation and for authorization a header with the x-api-key.
It is shown in the documentation correclty - see attached screenshot.

Is it possible that the request examples include this header request in the example.

E.g. instead of only the follwing in the api request (Javascript):
var myHeaders = new Headers();
myHeaders.append(“User-Agent”, “Apidog/1.0.0 (https://apidog.com)”);

var requestOptions = {
method: ‘GET’,
headers: myHeaders,
redirect: ‘follow’
};

This one:
var myHeaders = new Headers();
myHeaders.append(“User-Agent”, “Apidog/1.0.0 (https://apidog.com)”);
myHeaders.append(“x-api-key”, “YOUR_API_KEY”);

var requestOptions = {
method: ‘GET’,
headers: myHeaders,
redirect: ‘follow’
};

This would make the fast start for our customers easier. I havn’t foudn a way to add this.

Another question - is it possible to change the default UserAgent shown here?

Thanks & Best regards
Michael

Let me first clarify what you need to do

  1. Include your API Auth key in code samples
  2. Change Default UserAgent Shown in code samples.

For both questions, you can define the corresponding parameters in the Header tab and give them a fixed value, then you will see them shown in code samples.

But for security reasons, we still do not recommend that you display private information such as keys directly in public documents.


perfect that works, thanks for the fast help! :+1: