-
Notifications
You must be signed in to change notification settings - Fork 8
Authorization
Warning
Cookies authentication in 1.x.x is broken, either update to 2.x.x or use refresh tokens
To authenticate using cookies, you will need to extract the following cookies from a browser which is logged in to YouTube.
- SID
- HSID
- SSID
- APISID
- SAPISID
After getting the cookies, just set the Authorization
field in your InnerTubeConfiguration
to InnerTubeAuthorization.SapisidAuthorization("YOUR-SID-COOKIE", "YOUR-HSID-COOKIE", "YOUR-SSID-COOKIE", "YOUR-APISID-COOKIE", "YOUR-SAPISID-COOKIE")
, and it should work fine! For an example, you should check this file.
Note
While these cookies have never expired in our tests, its still recommended to use a refresh token instead.
Instead of using cookies that can expire, you can just use a refresh token that works just as well. You can get a refresh token by doing some debugger magic on the YouTube TV app.
- Visit https://youtube.com/tv
- You will need to get a TV user agent to access to the app. If your user agent is invalid, you will see this screen:
- You can bypass this message by using a user agent changer extension, and setting your user agent to one of the following:
Mozilla/5.0 (AppleTV; CPU OS 13_4_6 like Mac OS X) HW_AppleTV/5.3
Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/90.0.4430.212 Large Screen Safari/534.24 GoogleTV/092754
Mozilla/5.0 (PlayStation; PlayStation 4/8.50) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0 Safari/605.1.15
- You will need to get a TV user agent to access to the app. If your user agent is invalid, you will see this screen:
- Go to the sign in prompt located in the sidebar
- At this point, you should get your browser's DevTools up and switch to the network tab. Make sure that this tab is open BEFORE you sign in, and that persist logs is enabled.
- At this point, you should get your browser's DevTools up and switch to the network tab. Make sure that this tab is open BEFORE you sign in, and that persist logs is enabled.
- Follow the instructions on the screen, and look for a new request that goes to
https://www.youtube.com/o/oauth2/token
. There will be a lot of these, check all of them until one of them looks like the following
- Put the
refresh_token
from that response inside yourInnerTubeConfiguration
, like so:
If you did all the steps above correctly, you should now be authorized!
- Open the YouTube TV website as described above
- Log in to an account
- Run the following JavaScript snippet in your browser's JavaScript console.
JSON.parse(localStorage.getItem("yt.leanback.default::last-identity-used")).data.identityCredentials.refreshToken
- Paste the result inside your
InnerTubeConfiguration
, without quotes, like so: