arduino-youtube-api
arduino-youtube-api copied to clipboard
Added OAuth2 support and getMyRecentSubscribers
This current pull requests breaks backwards compatibility. Let me what you think is the best way to fix this.
I've implemented OAuth2 support because it's needed te access certain information like the most recent subscribers to a YouTube channel.
These are the steps I've used to get the authentication credentials:
- Create Client ID and Client Secret (use “other app") - see https://developers.google.com/youtube/v3/guides/auth/devices
- Get your device code (= the user_code in the return parameters) -
curl -d "client_id=YOUR_CLIENT_ID_FROM_STEP_1&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fyoutube.readonly" https://accounts.google.com/o/oauth2/device/code
- Copy the user_code value obtained in step 2
- Grant access via https://www.google.com/device using the user_code
- Get access token & refresh token -
curl -d "client_id=YOUR_CLIENT_ID_FROM_STEP_1&client_secret=YOUR_CLIENT_SECRET_FROM_STEP_1&code=YOUR_DEVICE_CODE_FROM_STEP_2&grant_type=http://oauth.net/grant_type/device/1.0" -H "Content-Type: application/x-www-form-urlencoded" https://www.googleapis.com/oauth2/v4/token
- Test the access token - open this url in your browser
https://www.googleapis.com/youtube/v3/channels?access_token=YOUR_ACCESS_TOKEN_FROM_STEP_5&part=snippet&mine=true
- Optional: command to manually refresh the access token (this is build into the lib) -
curl -d "client_id=YOUR_CLIENT_ID_FROM_STEP_1&client_secret=YOUR_CLIENT_SECRET_FROM_STEP_1&refresh_token=YOUR_REFRESH_TOKEN_FROM_STEP_5&grant_type=refresh_token" -H "Content-Type: application/x-www-form-urlencoded" https://www.googleapis.com/oauth2/v4/token