Skip to content

Commit

Permalink
Add dump method to Managed Token client.
Browse files Browse the repository at this point in the history
  • Loading branch information
EvieePy committed Mar 9, 2024
1 parent cc32e79 commit b71ea61
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions twitchio/authentication/tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import asyncio
import datetime
import json
import logging
from typing import TYPE_CHECKING, TypeVar

Expand Down Expand Up @@ -242,3 +243,11 @@ async def close(self) -> None:
self._validate_task = None

await super().close()

def dump(self, name: str | None = None) -> None:
name = name or ".tio.tokens.json"

with open(name, "w") as fp:
json.dump(list(self._tokens.values()), fp)

logger.info("Tokens from %s have been saved to %s.", self.__class__.__qualname__, name)

0 comments on commit b71ea61

Please sign in to comment.