Skip to content

Commit fbeda80

Browse files
committed
use authentication token correctly
1 parent da5f3df commit fbeda80

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

compose/backend/neurosynth_compose/resources/analysis.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -767,10 +767,12 @@ def _clone_project(self, source_id, copy_annotations):
767767
from auth0.authentication.get_token import GetToken
768768

769769
domain = current_app.config["AUTH0_BASE_URL"].lstrip("https://")
770-
g_token = GetToken(domain)
771-
token_resp = g_token.client_credentials(
772-
client_id=current_app.config["AUTH0_CLIENT_ID"],
770+
g_token = GetToken(
771+
domain,
772+
current_app.config["AUTH0_CLIENT_ID"],
773773
client_secret=current_app.config["AUTH0_CLIENT_SECRET"],
774+
)
775+
token_resp = g_token.client_credentials(
774776
audience=current_app.config["AUTH0_API_AUDIENCE"],
775777
)
776778
access_token = " ".join(
@@ -1033,10 +1035,12 @@ def create_or_update_neurostore_study(ns_study):
10331035
# use the client to authenticate if user credentials were not used
10341036
if not access_token:
10351037
domain = current_app.config["AUTH0_BASE_URL"].lstrip("https://")
1036-
g_token = GetToken(domain)
1037-
token_resp = g_token.client_credentials(
1038-
client_id=current_app.config["AUTH0_CLIENT_ID"],
1038+
g_token = GetToken(
1039+
domain,
1040+
current_app.config["AUTH0_CLIENT_ID"],
10391041
client_secret=current_app.config["AUTH0_CLIENT_SECRET"],
1042+
)
1043+
token_resp = g_token.client_credentials(
10401044
audience=current_app.config["AUTH0_API_AUDIENCE"],
10411045
)
10421046
access_token = " ".join([token_resp["token_type"], token_resp["access_token"]])

compose/backend/neurosynth_compose/resources/tasks.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,12 @@ def create_or_update_neurostore_analysis(
107107
# use the client to authenticate if user credentials were not used
108108
if not access_token:
109109
domain = app.config["AUTH0_BASE_URL"].lstrip("https://")
110-
g_token = GetToken(domain)
111-
token_resp = g_token.client_credentials(
112-
client_id=app.config["AUTH0_CLIENT_ID"],
110+
g_token = GetToken(
111+
domain,
112+
app.config["AUTH0_CLIENT_ID"],
113113
client_secret=app.config["AUTH0_CLIENT_SECRET"],
114+
)
115+
token_resp = g_token.client_credentials(
114116
audience=app.config["AUTH0_API_AUDIENCE"],
115117
)
116118
access_token = " ".join(

compose/backend/neurosynth_compose/tests/conftest.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,11 @@ def add_users(real_app, real_db):
406406
from neurosynth_compose.resources.auth import decode_token
407407

408408
domain = real_app.config["AUTH0_BASE_URL"].split("://")[1]
409-
token = GetToken(domain)
409+
token = GetToken(
410+
domain,
411+
real_app.config["AUTH0_CLIENT_ID"],
412+
client_secret=real_app.config["AUTH0_CLIENT_SECRET"],
413+
)
410414

411415
users = [
412416
{
@@ -424,8 +428,6 @@ def add_users(real_app, real_db):
424428
name = u["name"]
425429
passw = u["password"]
426430
payload = token.login(
427-
client_id=real_app.config["AUTH0_CLIENT_ID"],
428-
client_secret=real_app.config["AUTH0_CLIENT_SECRET"],
429431
username=name + "@email.com",
430432
password=passw,
431433
realm="Username-Password-Authentication",

0 commit comments

Comments
 (0)