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

OAuth token expired event for IRC and TwitchAPI #298

Closed
Syzuna opened this issue Nov 12, 2017 · 8 comments
Closed

OAuth token expired event for IRC and TwitchAPI #298

Syzuna opened this issue Nov 12, 2017 · 8 comments

Comments

@Syzuna
Copy link
Member

Syzuna commented Nov 12, 2017

Hey swiffty,

Is is possible to get an event when the irc login or an api call failed bcs the oauth token that is used is expired?

This would help alot!

Regards

Syzuna

@swiftyspiffy
Copy link
Member

Do you have an oauth that has expired or sample message that is received on expired oauth?

I don't have either so it's hard to test functionality for it.

@Syzuna
Copy link
Member Author

Syzuna commented Nov 12, 2017

twitch docs say:

When you make a request with expired or incorrect authorization credentials, the API returns a WWW-Authenticate header (with an invalid_token error) and a 401 Unauthorized status:

DELETE /kraken/users/test_user1/follows/channels/test_channel HTTP/1.1
Host: api.twitch.tv
User-Agent: curl/7.43.0
Accept: application/vnd.twitchtv.v3+json
Authorization: OAuth <access_token>
Client-ID: retgzhvpsxjwun0rvrb1rfwheegu1yw

HTTP/1.1 401 Unauthorized
Accept-Ranges: bytes
Access-Control-Allow-Headers:
Access-Control-Allow-Methods:
Access-Control-Allow-Origin: *
Age: 0
Cache-Control: max-age=0, private, must-revalidate
Content-Type: application/json; charset=utf-8
Date: Wed, 12 Oct 2016 22:25:10 GMT
Server: nginx
Status: 401 Unauthorized
Vary: Accept-Encoding
Via: 1.1 varnish
WWW-Authenticate: OAuth realm='TwitchTV', error='invalid_token'
Content-Length: 89
Connection: keep-alive

{
"error": "Unauthorized",
"message": "Token invalid or missing required scope",
"status": 401
}

Sadly I dont have any information how the IRC one looks

@Syzuna
Copy link
Member Author

Syzuna commented Nov 12, 2017

"On seeing a 401 error with a WWW-Authenticate header, an application should try to refresh the session if a refresh token is present. "

@swiftyspiffy
Copy link
Member

Ya, I do think it's a good idea to get some kind of event for the client when using an expired token, and an exception for the API. As for automatically refreshing the token, i don't think that's really possible without providing the twitch app secret + refresh token, which is nasty.

@Syzuna
Copy link
Member Author

Syzuna commented Nov 18, 2017

ye I dont need an auto refresh but sth to detect that I need to make a refresh call inside the lib would be nice

@Syzuna
Copy link
Member Author

Syzuna commented Nov 19, 2017

IRC only prints login failed into the console it seems

@swiftyspiffy
Copy link
Member

Since the referenced pull request is closed, just an update: This detection is completed for API, still needs to be done for TwitchClient.

@swiftyspiffy
Copy link
Member

This issue was moved to TwitchLib/TwitchLib.Client#41

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

2 participants