Skip to content

Commit 3655fa9

Browse files
author
Kevin Hannegan
committed
add client credentials to oidc
1 parent d1f5027 commit 3655fa9

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

presalytics/client/oidc.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,23 @@ def _handle_response(self, response):
251251
except Exception:
252252
pass
253253
return data
254+
255+
def client_credentials_token(self, scope=None):
256+
if not self.client_secret:
257+
raise presalytics.lib.exceptions.ApiError(message="Must have client secret for client credentials grant", status_code=400)
258+
if not scope:
259+
scope = self.default_scopes
260+
post_data = {
261+
"client_id": self.client_id,
262+
"client_secret": self.client_secret,
263+
"grant_type": "client_credentials",
264+
"audience": self.audience
265+
}
266+
repsonse = self._post(self.token_endpoint, data)
267+
268+
return self._handle_response(repsonse)
269+
270+
254271

255272

256273

0 commit comments

Comments
 (0)