Twasi / twasi-core

Core application and backend of the Twasi chatbot for Twitch.
MIT License
19 stars 4 forks source link

Allow every request to be done with auth context #24

Closed DieserMerlin closed 5 years ago

DieserMerlin commented 5 years ago

Decrease rate limiting problems by providing a bearer token for every request (as seen in https://dev.twitch.tv/docs/api/guide/#rate-limits)

Laraakaa commented 5 years ago

Architectual approach: It makes fully sense to seperate requests that need an user onto an own class. This can for example be seen here when requesting data about the specific user itself:

UserDTO user = TwitchAPI.helix().users().withAuth(personalCtx).getCurrentUser();

By specifiying withAuth, we insert the personal context which includes the access token that we want to provide.

List<UserDTO> = TwitchAPI.helix().users().getUsers(null, {"larcce"});

Now we need to insert an options object, I would do it like this:

List<UserDTO> = TwitchAPI.helix().users().getUsers(null, {"larcce"}, new TwitchRequestOptions().withAuth(personalContext));

We can also extend the options object later on. This will be useful when it comes to rate limiting.

Laraakaa commented 5 years ago

https://github.com/Twasi/twitch-web-api/commit/75f6feea7979b9bbc820ea0ab3aa6f77c7f7af59