Skip to content

Commit

Permalink
fix: determine correct audience based on HELSINKI_PROFILE_API_URL
Browse files Browse the repository at this point in the history
  • Loading branch information
sirtawast committed Jun 18, 2024
1 parent c8d47d9 commit e2e0046
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion backend/shared/shared/helsinki_profile/hp_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,21 @@ def get_api_access_token_tunnistus(self, oidc_access_token):
"""
Exchanges OIDC access token for API access token using Tunnistus Keycloak
"""

if "test" in settings.HELSINKI_PROFILE_API_URL:
audience = "-test"
elif "stage" in settings.HELSINKI_PROFILE_API_URL:
audience = "-stage"
else:
audience = "" # production

audience = settings.HELSINKI_PROFILE_API_URL

try:
response = requests.post(
settings.TUNNISTUS_API_TOKENS_ENDPOINT,
data={
"audience": "profile-api-test", # TODO: use setting
"audience": f"profile-api{audience}", # TODO: use setting
"grant_type": "urn:ietf:params:oauth:grant-type:uma-ticket",
"permission": "#access",
},
Expand Down

0 comments on commit e2e0046

Please sign in to comment.