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

Enable constructing a authClient with a token #37

Open
tevonsb opened this issue Aug 16, 2022 · 6 comments
Open

Enable constructing a authClient with a token #37

tevonsb opened this issue Aug 16, 2022 · 6 comments

Comments

@tevonsb
Copy link

tevonsb commented Aug 16, 2022

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.

@apecollector
Copy link

apecollector commented Oct 14, 2022

Absolutely agree, the workarounds and open PR for this issue are very complicated for a simple bot example.

#25
#42

@rojvv
Copy link
Contributor

rojvv commented Oct 14, 2022

This is my workaround, you can do the same until the feature is implemented:

https://github.com/roj1512/rtwtrbt/blob/main/auth.ts

@rojvv
Copy link
Contributor

rojvv commented Oct 14, 2022

Simply, in your app, you can just extend the main auth class.

@ugglr
Copy link

ugglr commented Dec 6, 2022

+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.

@rojvv
Copy link
Contributor

rojvv commented Dec 6, 2022

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.

@ugglr
Copy link

ugglr commented Dec 7, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants