Migrating from YouTube ClientLogin to OAuth 2.0

I have an application that uploads videos on YouTube to a specific YouTube channel (which means not for a separate user channel, but for one channel for which I have a username and password).

At ClientLogin, my server process provided YouTube U / P, and everything is moving forward. However, since this has been deprecated, and I am looking for an upgrade to OAuth 2.0 (in accordance with their recommendation), however, the documentation insists on having a redirect URI when the user is logged in. It does not seem to explain how to bypass the user's login (since the user has nothing to log into the system or any credentials for logging in * s ... the application is designed to video them and upload it to our channel). So, I need to get around the user who was requested, and for YouTube just take the credentials of my channel and return me the token for downloading using.

I understand that this is an absolutely standard and consistent procedure, so I * MUST skip something obvious, but I just can not understand what it is.

So my question is: how do I skip the user dialog -> redirect and just provide the youtube credentials for accepting it, and then upload my video to OAuth 2.0?

What I really need is to follow the DirectUpload approach: https://developers.google.com/youtube/2.0/developers_guide_protocol#AuthSub_Authentication_Flow And to quietly pull the token user backstage.

TIA

+5
source share
1 answer

( ) OAuth2.0. , " " code.google.com/apis/console . . . , , , code.google.com/apis/youtube/dashboard/

JSON , .

POST accounts.google.com/o/oauth2/device/code

{
    'Content-Type': 'application/x-www-form-urlencoded',
    'Content-Length': post_data.length,
    'X-GData-Key': 'key=YOUR_DEVELOPER_KEY'
}

, :

{
client_id: 'YOUR_CLIENT_ID',
scope: 'https://gdata.youtube.com'
}

YOUR_CLIENT_ID - , google apis, .

:

{
  "device_code" : "4/Pj8m71w5XuEMTT0ZwOJVgvlTfF4Q",
  "user_code" : "5wtw67wm",
  "verification_url" : "http://www.google.com/device",
  "expires_in" : 1800,
  "interval" : 5
}

www.google.com/device ( "verify_url" ) 30 (1800 "expires_in" ), . www.google.com/device , , ( "user_code" ). , . ( ) "device_code". .

, , /. , . /, POST accounts.google.com/o/oauth2/token

{
    'Content-Type': 'application/x-www-form-urlencoded',
    'Content-Length': post_data.length,
    'X-GData-Key': 'key=YOUR_DEVELOPER_KEY'
}

{
    client_id: 'YOUR_CLIENT_ID',
    client_secret: 'YOUR_CLIENT_SECRET',
    code: 'YOUR_DEVICE_CODE',
    grant_type: 'http://oauth.net/grant_type/device/1.0'
}

:

{
  "access_token" : "YOUR_ACCESS_TOKEN",
  "token_type" : "Bearer",
  "expires_in" : 3600,
  "refresh_token" : "YOUR_REFRESH_TOKEN"
}

, 3600 (60 ) . .

API , , . :

{
    'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
    'X-GData-Key': 'key=YOUR_DEVELOPER_KEY',
    'Slug': 'video.mp4',
    'Content-Type': 'multipart/related; boundary="f897a6d"',
    'Content-Length': post_length,
    'Connection': 'close'
}

, . , POST accounts.google.com/o/oauth2/token

{
    'Content-Type': 'application/x-www-form-urlencoded',
    'Content-Length': post_data.length,
    'X-GData-Key': 'key=YOUR_DEVELOPER_KEY'
}

{
    client_id: 'YOUR_CLIENT_ID',
    client_secret: 'YOUR_CLIENT_SECRET',
    refresh_token: 'YOUR_REFRESH_TOKEN',
    grant_type: 'refresh_token'
}

{
  "access_token" : "YOUR_NEW_ACCESS_TOKEN",
  "token_type" : "Bearer",
  "expires_in" : 3600
}

YOUR_NEW_ACCESS_TOKEN - .

+6

All Articles