Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added OAuth2 support and getMyRecentSubscribers #6

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

marcfon
Copy link

@marcfon marcfon commented Jun 28, 2017

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.

@marcfon
Copy link
Author

marcfon commented Jun 28, 2017

These are the steps I've used to get the authentication credentials:

  1. Create Client ID and Client Secret (use “other app") - see https://developers.google.com/youtube/v3/guides/auth/devices
  2. 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
  3. Copy the user_code value obtained in step 2
  4. Grant access via https://www.google.com/device using the user_code
  5. 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
  6. 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
  7. 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant