Skip to content

Commit 783caed

Browse files
Merge pull request #69 from RelationalAI/pv-override-auth0-audience
add config option for overriding auth0 audience
2 parents e00fa95 + 2ab1f35 commit 783caed

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

railib/api.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,12 @@ class Permission(str, Enum):
136136
# Context contains the state required to make rAI API calls.
137137
class Context(rest.Context):
138138
def __init__(self, host: str = None, port: str = None, scheme: str = None,
139-
region: str = None, credentials=None):
139+
region: str = None, credentials=None, audience: str = None):
140140
super().__init__(region=region, credentials=credentials)
141141
self.host = host
142142
self.port = port or "443"
143143
self.scheme = scheme or "https"
144+
self.audience = audience
144145

145146

146147
# Construct a URL from the given context and path.

railib/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def read(fname: str = "~/.rai/config", profile: str = "default"):
8484
raise Exception(f"can't find file: {path}")
8585
data = _read_config_profile(path, profile)
8686
creds = _read_credentials(data, path)
87-
_keys = ["host", "port", "region", "scheme"]
87+
_keys = ["host", "port", "region", "scheme", "audience"]
8888
result = {k: v for k, v in data.items() if k in _keys}
8989
result["credentials"] = creds
9090
return result

railib/rest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def _request_access_token(ctx: Context, url: str) -> AccessToken:
131131
creds = ctx.credentials
132132
assert type(creds) == ClientCredentials
133133
# ensure the audience contains the protocol scheme
134-
audience = f"https://{_get_host(url)}"
134+
audience = ctx.audience or f"https://{_get_host(url)}"
135135
headers = {
136136
"Accept": "application/json",
137137
"Content-Type": "application/json",

0 commit comments

Comments
 (0)