Closed KeziahMoselle closed 2 years ago
Seems like it is not possible to run an interval since cache_token
is never being invalidated since it just checks for a truthy value.
https://github.com/cyperdark/osu-api-extended/blob/master/src/api/v2/index.ts#L21
What I did for a project is something along thoses lines:
if (
(this.tokenExpire && new Date() > this.tokenExpire) ||
!this.tokenExpire
) {
console.log('osu! API v2 access_token is expired or needs to be created')
await this.getToken()
}
oh, let me added this
With the API login osu should return
{
"access_token": "verylongstring",
"expires_in": 86400,
"refresh_token": "anotherlongstring",
"token_type": "Bearer"
}
technically you can use the refresh_token
if the lease expires to instantly request a new access_token
. This is probanly a better way of doing it then to compleatly relogging like proposed.
But from what ive seen so far the refresh_token
gets compleatly thrown away.
i guess auto refresh is working but i can't test it properly, and also there new way to auth now will make a migrate.md for it and will push
new version is published
migration https://github.com/cyperdark/osu-api-extended/blob/master/changes/2.1.2.md
Nice thanks @cyperdark!
So I tried running my server for more than 24 hours and it was yielding the auth error, Is it a me problem or it doesn't seem to work? :(
hmm, let me see
new version is out
@cyperdark after 24 hours 😢 (I am calling the auth method before each API call)
bruh, i guess i need to run debug for a 24 hours to see why its failing
update the package, i hope this one will work
i have not that much time to test/work on package, so i make a temporary fix. Will try to fix it later when i finish one thing
Sure thing don't worry Updated, will let you know!
Look like it works with this temp fix 👍
nice to hear that
i pushed new version, could i ask you to test it (was complete rewrited)
also docs are look better now https://github.com/cyperdark/osu-api-extended/wiki
some sort of migration https://github.com/cyperdark/osu-api-extended/blob/master/changes/2.5.0.md
Do I still need to call auth.login()
in each of my files? From what I've seen, you are relogging if the request yield the auth error, does that mean I can just run auth.login()
in my root file and everywhere else just doing resources calls ?
once, in any files and then it will work in any files
Not an issue but title.
Do I need to run my own interval to refresh the access token? Because it seems like the library does not support auto refresh