Steps to Authenticate Using Bearer Token
Obtain Your Access JWT Token
To start, make a POST request to the /login
route with your client_id
and client_secret
. This will return an access_token
(JWT).
The client_id
and client_secret
are credentials that allow the server to verify your identity.
Example POST Request:
curl -X POST https://ai.propershot.com/v1/login \
-H "Content-Type: application/json" \
-d '{
"client_id": "your_client_id",
"client_secret": "your_client_secret"
}'
Example Response:
{
"access_token": "eyJhbGcpiI****",
"token_type": "Bearer",
"expires_in": 2210689
}
Note: Keep your client_id
, client_secret
, and access token private and secure.
Include the Access Token in the Authorization Header
For each request to the API, include the access token in the Authorization header using the Bearer schema. The structure of the Authorization header will look like this:
Authorization: Bearer <Your_Access_Token>
Example:
Authorization: Bearer eyJhbGciOi***
Making an API Request with the Bearer Token
Once you have the access token, you can include it in the Authorization header for every API request. Below is an example using cURL
:
Example cURL Request:
curl -X POST https://ai.propershot.com/v1/service/listing-generation \
-H "Authorization: Bearer your_jwt_token" \
-H "Content-Type: application/json"
Sample Requests Using Bearer Token in Different Languages
1. JavaScript (Fetch API)
POST Request Example:
fetch('https://ai.propershot.com/v1/service/listing-generation', {
method: 'POST',
headers: {
'Authorization': 'Bearer your_jwt_token',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"image_url": "https://example.com/image.jpg"
})
})
.then(response => response.json())
.then(data => console.log('Success:', data))
.catch(error => console.error('Error:', error));
2. Shell (cURL)
POST Request Example:
curl -X POST https://ai.propershot.com/v1/service/listing-generation \
-H "Authorization: Bearer your_jwt_token" \
-H "Content-Type: application/json" \
-d '{
"image_url": "https://example.com/image.jpg"
}'
3. Python (requests library)
POST Request Example:
import requests
url = 'https://ai.propershot.com/v1/service/listing-generation'
headers = {
'Authorization': 'Bearer your_jwt_token',
'Content-Type': 'application/json'
}
data = {
'image_url': 'https://example.com/image.jpg'
}
response = requests.post(url, headers=headers, json=data)
if response.status_code == 200:
print('Success:', response.json())
else:
print('Error:', response.status_code, response.text)