Authentication
To use our APIs, you need to authenticate your requests. At Natech, we support two methods of authentication:
API Key Authentication​
Include your API key in the header of each request:
Authorization: Bearer YOUR_API_KEY
OAuth 2.0​
For more secure applications, we recommend using OAuth 2.0[https://oauth.net/2/]. Here's how to get an access token:
- Redirect the user to our authorization URL
- Receive the authorization code
- Exchange the code for an access token
- cURL
- Python
- JavaScript
curl -X POST https://api.example.com/oauth/token \\
-d "grant_type=authorization_code" \\
-d "client_id=YOUR_CLIENT_ID" \\
-d "client_secret=YOUR_CLIENT_SECRET" \\
-d "code=AUTHORIZATION_CODE"
import requests
data = {
'grant_type': 'authorization_code',
'client_id': 'YOUR_CLIENT_ID',
'client_secret': 'YOUR_CLIENT_SECRET',
'code': 'AUTHORIZATION_CODE'
}
response = requests.post('https://api.example.com/oauth/token', data=data)
access_token = response.json()['access_token']
const data = new URLSearchParams();
data.append('grant_type', 'authorization_code');
data.append('client_id', 'YOUR_CLIENT_ID');
data.append('client_secret', 'YOUR_CLIENT_SECRET');
data.append('code', 'AUTHORIZATION_CODE');
fetch('https://api.example.com/oauth/token', {
method: 'POST',
body: data
})
.then(response => response.json())
.then(data => {
const accessToken = data.access_token;
});