Getting a YouTube (or other Google product/service) refresh token using Google’s OAuth 2.0 Playground is easy. Just follow this brief tutorial.
Go to the OAuth 2.0 Playground. Within Step 1 (Select & authorize APIs), scroll down and click on YouTube Data API v3. Then click on https://www.googleapis.com/auth/youtube.upload. Then click Authorize APIs.
You will now be taken to a screen that will inform you Google OAuth 2.0 Playground would like to Manage your YouTube videos. Click Allow.
Make sure the checkbox is checked for Auto-refresh the token before it expires. Then click Exchange authorization code for tokens.
To the right, below Request / Response, copy the following code and save them to a file called token.txt.