Skip to content

Commit

Permalink
Added automatic access_token refresh when they expire. (#346)
Browse files Browse the repository at this point in the history
* Added automatic access_token refresh when they expire.

* Updating requirements

* Updating requirements

* Updating requirements

* Updating requirements

* Updating requirements

* Added Python2 handling

* [client] better handling for refresh_token

---------

Co-authored-by: Steven <steven.pi@studiosouza.be>
Co-authored-by: Evan Blaudy <evan@cg-wire.com>
  • Loading branch information
3 people authored Dec 13, 2024
1 parent 27d2c05 commit 32b80b7
Show file tree
Hide file tree
Showing 4 changed files with 239 additions and 56 deletions.
18 changes: 2 additions & 16 deletions gazu/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,22 +87,8 @@ def log_out(client=raw.default_client):
return tokens


def refresh_token(client=raw.default_client):
headers = {"User-Agent": "CGWire Gazu %s" % __version__}
if "refresh_token" in client.tokens:
headers["Authorization"] = "Bearer %s" % client.tokens["refresh_token"]

response = client.session.get(
raw.get_full_url("auth/refresh-token", client=client),
headers=headers,
)
raw.check_status(response, "auth/refresh-token")

tokens = response.json()

client.tokens["access_token"] = tokens["access_token"]

return tokens
def refresh_access_token(client=raw.default_client):
return client.refresh_access_token()


def get_event_host(client=raw.default_client):
Expand Down
Loading

0 comments on commit 32b80b7

Please sign in to comment.