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

create .rai if necessary #147

Merged
merged 1 commit into from Mar 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion railib/rest.py
Expand Up @@ -16,7 +16,7 @@

import json
import logging
from os import path
from os import path, makedirs
from urllib.error import URLError
from urllib.parse import urlencode, urlsplit, quote
from urllib.request import Request, urlopen
Expand Down Expand Up @@ -151,6 +151,8 @@ def _read_token_cache(creds: ClientCredentials) -> AccessToken:
# write access token to cache
def _write_token_cache(creds: ClientCredentials):
try:
cache_dir = path.dirname(_cache_file())
makedirs(cache_dir, exist_ok=True)
cache = _read_cache()
cache[creds.client_id] = creds.access_token
with open(_cache_file(), 'w') as f:
Expand Down