Skip to content

Latest commit

 

History

History
 
 

youtube

YouTube

Android client

Must use Android API 31 or higher.

https://android.stackexchange.com/a/245551

Device OAuth

How to get X-Goog-Api-Key

Make a request like this:

GET / HTTP/2
Host: www.youtube.com

in the response you should see something like this:

"INNERTUBE_API_KEY":"AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8"

https://cloud.google.com/apis/docs/system-parameters

How to get client_id and client_secret

Set User-Agent to [1]:

Mozilla/5.0 (ChromiumStylePlatform) Cobalt/Version

Then visit:

https://www.youtube.com/tv

Next open your browser menu, and click Web Developer, Network or similar. Then go back to the page, and click "Sign in", then "Sign in with a web browser". On the next page, dont bother with any of the instructions, just go back to Developer Tools, and after about five seconds you should see a JSON request like this:

POST /o/oauth2/token HTTP/1.1
Host: www.youtube.com

{"client_id":"861556708454-d6dlm3lh05idd8npek18k6be8ba3oc68.apps.googleusercontent.com",
"client_secret":"SboVhoG9s0rNafixCSGGKXAT",
"code":"AH-1Ng14qVvEj76OeM_h14Mgklgyhchbyc67MhULhCKPY6K-0DTYJqaKng2ULVFTmTzU...",
"grant_type":"http://oauth.net/grant_type/device/1.0"}
  1. https://github.com/youtube/cobalt/blob/master/src/cobalt/browser/user_agent_string.cc

Image

Is maxres1 always available? No:

Is sd1 always available? No:

If hq1 always available? Yes:

http://i.ytimg.com/vi/hq2KgzKETBw/hq1.jpg

Why does this exist?

I use it myself:

https://www.youtube.com/watch?v=zv9NimPx3Es

April 8 2022