Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added automatic access_token refresh when they expire. #346

Merged
merged 8 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading