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

[RFE] Improve Auth Management #38

Closed
mitchwadair opened this issue Nov 6, 2021 · 0 comments · Fixed by #55
Closed

[RFE] Improve Auth Management #38

mitchwadair opened this issue Nov 6, 2021 · 0 comments · Fixed by #55
Assignees
Labels
enhancement New feature or request

Comments

@mitchwadair
Copy link
Owner

mitchwadair commented Nov 6, 2021

Is your feature request related to a problem? Please describe.
Currently every request to Twitch made be TES validates the access token first. This could cause some rate-limiting issues (maybe, not sure how those are handled) for users of the library that have large loads of users or something that would cause them to need to make those calls. It also makes every operation requiring the API very inefficient, especially those using pagination.

Describe the solution you'd like
An auth service type thing that manages the app access token and refreshing it. This should also mean that should a request be made where an invalid token is used (is possible, and could also happen with some extremely rare timing), that it is handled as well.

The auth service should (for app access tokens, i.e. for webhooks users), should store the current token and refresh token and schedule token refresh. It should also periodically verify the token. Periodic verification should either happen on some kind of timer, or maybe randomly before some requests are made. A good way to maybe do this is have some kind of request manager that would select some requests to verify every so often

Some possible examples of usage:

import AuthService from "authservicepath";
const token  = AuthService.getToken();
fetch("someurl", {method: "GET", headers: { "Authorization": `Bearer ${token}` }})
    .then(res => res.json())
    .then(data => {
        // do things
    })
    .catch(err => {
        if (err.message === "token not valid") {
            AuthService.refreshToken();
            // somehow make request again
            // maybe this would be a good thing for a request manager to deal with??
        }
    });
@mitchwadair mitchwadair added the enhancement New feature or request label Nov 6, 2021
mitchwadair added a commit that referenced this issue Aug 27, 2022
mitchwadair added a commit that referenced this issue Aug 27, 2022
@mitchwadair mitchwadair self-assigned this Aug 27, 2022
mitchwadair added a commit that referenced this issue Aug 27, 2022
mitchwadair added a commit that referenced this issue Aug 27, 2022
mitchwadair added a commit that referenced this issue Aug 27, 2022
mitchwadair added a commit that referenced this issue Aug 27, 2022
mitchwadair added a commit that referenced this issue Aug 28, 2022
mitchwadair added a commit that referenced this issue Aug 28, 2022
mitchwadair added a commit that referenced this issue Aug 28, 2022
mitchwadair added a commit that referenced this issue Aug 28, 2022
mitchwadair added a commit that referenced this issue Aug 28, 2022
mitchwadair added a commit that referenced this issue Aug 28, 2022
mitchwadair added a commit that referenced this issue Aug 28, 2022
mitchwadair added a commit that referenced this issue Aug 28, 2022
mitchwadair added a commit that referenced this issue Aug 28, 2022
mitchwadair added a commit that referenced this issue Aug 28, 2022
mitchwadair added a commit that referenced this issue Aug 28, 2022
mitchwadair added a commit that referenced this issue Aug 28, 2022
mitchwadair added a commit that referenced this issue Aug 28, 2022
mitchwadair added a commit that referenced this issue Aug 28, 2022
mitchwadair added a commit that referenced this issue Aug 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant