Use API Tokens

API tokens can be used with both the REST API and GraphQL API. To use the token, it must be supplied as part of the Authorization header made as part of the HTTP request:

http
Authorization Bearer pHUw1oLASALFmt2ppNvwCR0Meo2nHQ15~ECViF0Ce95uIqFGSSatjKWX71EOzvkpVGSuc3zGYqJgR

For example, the following Python script creates a new repository.

python
import requests
import json 

query = """mutation { 
createRepository(name : "SampleRepository") { 
  id 
} 
} 
""" 

headers = {"Authorization":
"Bearer pHUw1oLASALFmt2ppNvwCR0Meo2nHQ15~ECViF0Ce95uIqFGSSatjKWX71EOzvkpVGSuc3zGYqJgR"}

url = 'http://example.com:8080/graphql' 
r = requests.post(url, headers=headers, json={'query': query})

print(r.status_code) 
print(r.text) 

json_data = json.loads(r.text) 

print(json_data)

For more information on executing API queries, see Application Programming Interfaces (APIs).

Use an Expired API Token

If you try to submit an API request using an API token that has expired, LogScale will return HTTP response code 401 and a message noting that the authentication is invalid:

http
401 The supplied authentication is invalid

Expired tokens cannot be extended or renewed; the token will need to be recreated.

Use an IP Filtered API Token

When using a token that has an IP filter applied that restricts access to the current client, LogScale will respond with HTTP response code 403 and a message noting that the IP filter is present:

http
403
Tokens can only be used from IP addresses accepted by the IP
filter set for them if any.

Filtered tokens cannot be modified, but must be recreated with the correct IP filter applied.