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

TwitchHttpClient can have a more accurate message #210

Open
JDR-Ninja opened this issue Jul 24, 2021 · 3 comments
Open

TwitchHttpClient can have a more accurate message #210

JDR-Ninja opened this issue Jul 24, 2021 · 3 comments

Comments

@JDR-Ninja
Copy link

Hello,
The method TwitchLib.Api.Core.HttpCallHandlers.TwitchHttpClient.HandleWebException throw a BadTokenException when the api return 403.
But in some case, the returned message from the api is :
{
"error": "Forbidden",
"status": 403,
"message": "channel points are not available for the broadcaster"
}
But TwitchHttpClient will hide this information and return a bad token message.
I tested this issue with my account (new twitch account) and called "Helix.ChannelPoints.GetCustomReward".
I searched for a long time before realizing that my token was correct, but the problem was that my channel did not support the functionality.

@Syzuna
Copy link
Member

Syzuna commented Jul 24, 2021

Yes we know this is not ideal but the library pre dates Helix and its standard error messages and back then we only had Status codes to work with.
Changing it would be a big change and most likely also would cause a lot of hacked together code.. so I guess this wont be done until v5 is removed and we got time to rewrite the library completely (sth we are planning for some time now).
Sorry :/

@Syzuna
Copy link
Member

Syzuna commented Mar 17, 2023

While it isnt ideal it is at least sth.
With 3.9.0 you can now do:

            try
            {
               // API call
            }
            catch (HttpResponseException e)
            {
                Console.WriteLine(await e.HttpResponse.Content.ReadAsStringAsync());
            }

@Felk
Copy link

Felk commented Apr 5, 2023

With a bunch of chat functionality being moved over to Helix, I suspect this will trip quite a few more people now. For example, when whispering a user Twitch might return a status code 403 with the message

The recipient's settings prevent this sender from whispering them

but TwitchLib outputs this error, which can misguide people quite badly:

TwitchLib.Api.Core.Exceptions.BadTokenException: The token provided in the request did not match the associated user. Make sure the token you're using is from the resource owner (streamer? viewer?)

Would it be acceptable to generify the error message a bit? I believe a less helpful message would be better than a misleading one.

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

3 participants