Closed Tempystral closed 4 years ago
You can use api.login ()
to refresh the token for a period of time (such as two hours) after login.
async with PixivClient() as client:
aapi = AppPixivAPI(client=client)
await aapi.login(username, password)
...
await aapi.login() # to refresh token
or use a function to complete this operation regularly
async def TokenRefresh(api):
while True:
await api.login()
await asycnio.sleep(7200)
Oh, I see. I hadn't realized it was that simple. Thanks a bunch!
I'm building a discord bot which periodically accesses Pixiv using this API and it works great... for a few hours. Every time we restart the bot, it logs in and locates images just fine, but then it mysteriously stops working.
I suspect this is because we require a new token, but it's not clear how to obtain one when the old token expires. We're currently logging in using a username and password.
Would you be able to shed any light on this matter? I've been looking for documentation on the Pixiv API but it's rather sparse.