Skip to content

Commit 9d01934

Browse files
committed
chore: add "Bearer" prefix to authorization headers [ENG-6467]
[ENG-6467](https://stacklet.atlassian.net/browse/ENG-6467) ### what add the "Bearer" type prefix for authorization headers using the token ### why it's more standard ### testing tested against sandbox ### docs n/a
1 parent 2e5c83f commit 9d01934

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

stacklet/client/platform/commands/cube.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,15 @@ def _run_query(ctx, query):
6363
context = StackletContext(ctx.obj["config"], ctx.obj["raw_config"])
6464
token = get_token()
6565

66-
url = f"https://{context.config.cubejs}/cubejs-api/v1/load"
66+
url = f"{context.config.cubejs}/cubejs-api/v1/load"
6767

6868
data = {"query": query}
6969
response = requests.post(
7070
url=url,
71-
headers={"Authorization": token, "Content-Type": "application/json"},
71+
headers={
72+
"Authorization": f"Bearer {token}",
73+
"Content-Type": "application/json",
74+
},
7275
data=json.dumps(data),
7376
)
7477
return response.json()
@@ -78,7 +81,7 @@ def _get(ctx, path: str):
7881
context = StackletContext(ctx.obj["config"], ctx.obj["raw_config"])
7982
token = get_token()
8083

81-
url = f"https://{context.config.cubejs}/cubejs-api/{path}"
84+
url = f"{context.config.cubejs}/cubejs-api/{path}"
8285

8386
response = requests.get(
8487
url=url,

stacklet/client/platform/executor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def __init__(self, context, token):
2828
self.session = requests.Session()
2929
self.session.headers.update(
3030
{
31-
"Authorization": self.token,
31+
"Authorization": f"Bearer {self.token}",
3232
}
3333
)
3434

tests/test_graphql.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def test_executor_run(self):
1414
executor, adapter = get_executor_adapter()
1515
self.assertEqual(executor.token, "foo")
1616
self.assertEqual(executor.api, "mock://stacklet.acme.org/api")
17-
self.assertEqual(executor.session.headers["authorization"], "foo")
17+
self.assertEqual(executor.session.headers["authorization"], "Bearer foo")
1818

1919
adapter.register_uri(
2020
"POST",

0 commit comments

Comments
 (0)