alamminsalo / orion

Cross platform Twitch.tv client
GNU General Public License v3.0
315 stars 60 forks source link

linux/ Can't login to Twitch using Chromium #266

Closed notzain closed 5 years ago

notzain commented 5 years ago

Built from master.

Attempting to log in, will open the Twitch authorization in Chromium. Authorizing Orion sends me to a localhost:8979 page, that can't be reached.

notzain commented 5 years ago

Actually, it authorizing worked fine on Firefox. Something to do with Chromium? It does not stay logged in, closing Orion logs me out again.

rakslice commented 5 years ago

Authorizing on the Twitch authorization page causes the browser to hit the built-in web server with a URL containing the access_token. When using Firefox, this has the form that Orion was originally designed for,

http://localhost:8979/?access_token=...&scope=user_read+...

When using Chrome, instead of passing the values as GET parameters (?foo=bar&baz=...) Twitch passes them in the fragment (#...), e.g.:

http://localhost:8979/#access_token=...&scope=user_read+...

The latter is actually what Twitch currently documents for the implicit code flow. https://dev.twitch.tv/docs/authentication/getting-tokens-oauth/#oauth-implicit-code-flow

Orion will need to detect this case and serve something to handle it.

rakslice commented 5 years ago

Whoops, I see there is already code to do this; I will investigate further...

rakslice commented 5 years ago

Orion is putting the response through a QDataStream. QDataStream isn't a general purpose binary stream writer; it is for converting structured data into a specific serialized representation. For instance it serializes a QByteArray as a big endian 4 byte length followed by the bytes of data of the array. So what Orion is sending out the socket is the bytes 00 00 00 ed followed by the response headers and the payload. It's actually amazing that this ever works with any browser at all!