Skip to content

Commit

Permalink
fix: Use backend to determine token auth mode: basic or post
Browse files Browse the repository at this point in the history
  • Loading branch information
frascuchon committed Nov 15, 2024
1 parent 054703a commit 6c671d9
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,21 @@ def _get_state_cookie_name(self) -> str:

async def _fetch_user_data(self, authorization_response: str, **oauth_query_params) -> dict:
oauth_client = self.new_oauth_client()
token_request_params = {**oauth_query_params}

Check warning on line 165 in argilla-server/src/argilla_server/security/authentication/oauth2/provider.py

View check run for this annotation

Codecov / codecov/patch

argilla-server/src/argilla_server/security/authentication/oauth2/provider.py#L165

Added line #L165 was not covered by tests

auth = None
if self._backend.use_basic_auth():
auth = httpx.BasicAuth(self.client_id, self.client_secret)

Check warning on line 169 in argilla-server/src/argilla_server/security/authentication/oauth2/provider.py

View check run for this annotation

Codecov / codecov/patch

argilla-server/src/argilla_server/security/authentication/oauth2/provider.py#L167-L169

Added lines #L167 - L169 were not covered by tests
else:
token_request_params["client_secret"] = self.client_secret

Check warning on line 171 in argilla-server/src/argilla_server/security/authentication/oauth2/provider.py

View check run for this annotation

Codecov / codecov/patch

argilla-server/src/argilla_server/security/authentication/oauth2/provider.py#L171

Added line #L171 was not covered by tests

token_url, headers, content = oauth_client.prepare_token_request(
self._token_endpoint,
authorization_response=authorization_response,
**oauth_query_params,
**token_request_params,
)

headers.update({"Accept": "application/json"})
auth = httpx.BasicAuth(self.client_id, self.client_secret)
async with httpx.AsyncClient(auth=auth) as session:
try:
response = await session.post(token_url, headers=headers, content=content)
Expand Down

0 comments on commit 6c671d9

Please sign in to comment.