forked from VNG-Realisatie/vng-api-common
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ Replace get_auth_headers with generate_jwt util
which can be reused in Open Zaak/Open Notificaties
- Loading branch information
Showing
2 changed files
with
20 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
def generate_jwt(client_id, secret, user_id, user_representation): | ||
from zgw_consumers.client import ZGWAuth | ||
|
||
class FakeService: | ||
def __init__(self, **kwargs): | ||
for key, value in kwargs.items(): | ||
setattr(self, key, value) | ||
|
||
auth = ZGWAuth( | ||
service=FakeService( # type: ignore | ||
client_id=client_id, | ||
secret=secret, | ||
user_id=user_id, | ||
user_representation=user_representation, | ||
) | ||
) | ||
return f"Bearer {auth._token}" |