Hello How do we authenticate when using locust. I...
# troubleshoot
r
Hello How do we authenticate when using locust. I have tried specifying the headers but gms logs still show request is missing authorization headers.
@early-lamp-41924 Please suggest.
For anyone facing this issue: Heres the modified working code for browse.py in perf-tests. <> are placeholders
Copy code
import json
from locust import HttpUser, between, task, events
url = "https://<yourdomain>/api/graphql"
payload = json.dumps({
  "query": "{\n  me {\n    corpUser {\n        username\n    }\n  }\n}",
  "variables": {}
})
headers = {
  'Authorization': 'Bearer <Your token>',
  'Content-Type': 'application/json'
}
class BrowseUser(HttpUser):
    wait_time = between(1, 5)
    def on_start(self):
        <http://self.client.post|self.client.post>(url, headers=headers, data=payload)
    @task
    def browse(self):
        <http://self.client.post|self.client.post>(
            "/entities?action=browse",
            json.dumps(
                {
                    "path": "/perf/test",
                    "entity": "dataset",
                    "start": 0,
                    "limit": 10,
                }
            ),
            headers=headers,
        )