Skip to content

Commit

Permalink
fix: handle both CLIENT_SECRET and certificate methods
Browse files Browse the repository at this point in the history
  • Loading branch information
paulschreiber committed Oct 20, 2023
1 parent b971971 commit 4dc19de
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions terraso_backend/apps/auth/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,15 +221,20 @@ def _build_client_secret(self):
)

def fetch_auth_tokens(self, authorization_code):
client_assertion = self._build_client_secret()
params = dict(
client_id=self.CLIENT_ID,
code=authorization_code,
grant_type="authorization_code",
redirect_uri=self.REDIRECT_URI,
client_assertion=client_assertion,
client_assertion_type="urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
)
if not self.CLIENT_SECRET:
params.update(
dict(
client_assertion=self._build_client_secret(),
client_assertion_type="urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
)
)

try:
resp = httpx.post(self.TOKEN_URI, data=params)
resp.raise_for_status()
Expand Down

0 comments on commit 4dc19de

Please sign in to comment.