-
Notifications
You must be signed in to change notification settings - Fork 4
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
Feature/access token magic 2 #19
base: main
Are you sure you want to change the base?
Conversation
Moves the source code from `src/researchtikpy` to `researchtikpy`. Removes and renames test files.
Use AccessToken for live tests, mocks for others. Skip one tests that causes an infinite loop.
Fix typo in example code for importing the AccessToken.
I personally think that simple caching with a time expiration does the job: @ttl_cache(ttl=7200 - 1) # to be safe
def get_access_token_cached() -> str:
client_key = os.environ["TIKTOK_CLIENT_KEY"]
client_secret = os.environ["TIKTOK_CLIENT_SECRET"]
logger.info("Getting access token...")
data: dict = get_access_token(
client_key=client_key, client_secret=client_secret
)
return data["access_token"] but if you like this class-based solution, fine with me :) |
See your point, there's definitely elegance to it. However, I'd like a solution where the API is in control of the expiration time. I'll check whether I can provide a simpler solution. |
Adds an
AccessToken
class that automatically gets and refreshes the bearer token from the OAuth endpoint.Tests are updated as well. However, in tests for
get_liked_videos
andget_user_followers
is an assertion error. I suggest retaining the tests as they are and fixing them, when merging with the refactored social graph implementations.