Enable constructing a authClient with a token
I have a token stored for multiple users. However the current sdk does not offer an option for me to auth.OAuth2User object using a token that I already have. Instead I always need to request an authUrl to set the internal this.token parameter.
This makes the auth.OAuth2User object nearly unusable since the instance will not persist, and is used by multiple different users.
I think there should be a setToken method or similar, so I can internally set the token, and then us the isTokenExpired and refreshAuthToken methods as normal.
Absolutely agree, the workarounds and open PR for this issue are very complicated for a simple bot example.
https://github.com/twitterdev/twitter-api-typescript-sdk/issues/25 https://github.com/twitterdev/twitter-api-typescript-sdk/pull/42
This is my workaround, you can do the same until the feature is implemented:
https://github.com/roj1512/rtwtrbt/blob/main/auth.ts
Simply, in your app, you can just extend the main auth class.
+1 Working with this SDK on the backend is pretty rough, every time the backend restarts I need to go manually and set a new token.
every time the backend restarts I need to go manually and set a new token.
This is not related to this library. Twitter revokes the token after a couple of hours if you or your backend don't refresh it.
every time the backend restarts I need to go manually and set a new token.
This is not related to this library. Twitter revokes the token after a couple of hours if you or your backend don't refresh it.
What you describe is the correct behavior, that's why we have a refresh token.
What I'm referring to is related to this library, I store the refresh token in my database, but I cannot use it when the access token expires.