views:

1062

answers:

1

Anyone out there have experience with the YouTube/Google API?

I am trying to login to Google/Youtube using clientLogin, retrieve an AuthSub token, exchange it for a multi-session token and then use it in our upload form. Just a note that we are not going to have other users logging into our (secure) website, this is for our use only (no multi-users). We just want a way to upload videos to our YT account via our own website without having to login/upload to YouTube.

Ultimately, everything is dependent on the first step. My AuthSub token is always being returned as invalid (Error '403').

All the steps I used are below with username/password changed. Anyone have an insight on why my AuthSub is always invalid? I am spending an enormous amount of time trying to get this to work.

STEP 1: Getting the authsub token from Youtube/Google

POST /youtube/accounts/ClientLogin HTTP/1.1
User-Agent: curl/7.10.6 (i386-redhat-linux-gnu) libcurl/7.10.6 OpenSSL/0.9.7a ipv6 zlib/1.1.4
Host: www.google.com
Pragma: no-cache
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
Content-Type:application/x-www-form-urlencoded
Content-Length: 86
Email=MyGoogleUsername&Passwd=MyGooglePasswd&accountType=GOOGLE&service=youtube&source=Test

RESPONSE RECEIVED:

Auth=AIwbFAR99f3iACfkT-5PXCB-1tN4vlyP_1CiNZ8JOn6P-......yv4d4zeGRemNm4il1e-M6czgfDXAR0w9fQ YouTubeUser=MyYouTubeUsername

CURL COMMAND USED:

/usr/bin/curl 
-S 
-v 
--location
https://www.google.com/youtube/accounts/ClientLogin
--data
Email=MyGoogleUsername&Passwd=MyGooglePasswd&accountType=GOOGLE&service=youtube&source=Test
--header
Content-Type:application/x-www-form-urlencoded

STEP 2: Exchanging the AuthSub token for a multi-use token

GET /accounts/AuthSubSessionToken HTTP/1.1
User-Agent: curl/7.10.6 (i386-redhat-linux-gnu) libcurl/7.10.6 OpenSSL/0.9.7a ipv6 zlib/1.1.4
Host: www.google.com
Pragma: no-cache
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
Content-Type:application/x-www-form-urlencoded
Authorization: AuthSub token="AIwbFASiRR3XDKs......p5Oy_VA_9U2yV1enxJoVGSgMlZqTcjKw9mS861vlc9GWTH9D9sQ"

Response received:

403 Invalid AuthSub token.

curl command used:

/usr/bin/curl 
-S 
-v
--location
https://www.google.com/accounts/AuthSubSessionToken
--header
Content-Type:application/x-www-form-urlencoded
-H
Authorization: AuthSub token="AIwbFAQR_4xG2g.....vp3BQZW5XEMyIj_wFozHSTEQ-BQRfYuIY-1CyqLeQ"

STEP 3: Checking to see if the token is good/valid

GET /accounts/AuthSubTokenInfo HTTP/1.1
User-Agent: curl/7.10.6 (i386-redhat-linux-gnu) libcurl/7.10.6 OpenSSL/0.9.7a ipv6 zlib/1.1.4
Host: www.google.com
Pragma: no-cache
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
Content-Type:application/x-www-form-urlencoded
Authorization: AuthSub token="AIwbFASiRR3XDKsNkaIoPaujN5RQhKs3u.....A_9U2yV1enxJoVGSgMlZqTcjKw9mS861vlc9GWTH9D9sQ"

Received response:

403 Invalid AuthSub token.

curl command used:

/usr/bin/curl
-S 
-v
--location
https://www.google.com/accounts/AuthSubTokenInfo
--header
Content-Type:application/x-www-form-urlencoded
-H
Authorization: AuthSub token="AIwbFAQR_4xG2gHoAKDsNdFqdZdwWjGeNquOLpvp3BQZW5XEMyIj_wFozHSTEQ-BQRfYuIY-1CyqLeQ"

STEP 4: Trying to get the upload token using the authsub token

POST /action/GetUploadToken HTTP/1.1
User-Agent: curl/7.10.6 (i386-redhat-linux-gnu) libcurl/7.10.6 OpenSSL/0.9.7a ipv6 zlib/1.1.4
Host: gdata.youtube.com
Pragma: no-cache
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
Content-Type:application/atom+xml
Authorization: AuthSub token="AIwbFASiRR3XDKsNkaIoPaujN5RQhp5Oy_VA_9U2yV1enxJoVGSgMlZqTcjKw9mS861vlc9GWTH9D9sQ"
X-Gdata-Key:key="AI39si5EQyo-TZPFAnmGjxJGFKpxd_7a6hEERh_3......R82AShoQ"
Content-Length:0
GData-Version:2

Recevied Response:

401 Token invalid - Invalid AuthSub token.

Curl command used:

/usr/bin/curl
-S
-v
--location
http://gdata.youtube.com/action/GetUploadToken
-H
Content-Type:application/atom+xml
-H
Authorization: AuthSub token="AIwbFASiRR3XDKs....sYDp5Oy_VA_9U2yV1enxJoVGSgMlZqTcjKw9mS861vlc9GWTH9D9sQ"
-H
X-Gdata-Key:key="AI39si5EQyo-TZPFAnmGjxJGF......Kpxd6dN2J1oHFQYTj_7a6hEERh_3E48R82AShoQ"
-H
Content-Length:0
-H
GData-Version:2
+1  A: 

ClientLogin does not return AuthSub tokens. They are unrelated.

Jonathan