English 中文(简体)
AuthSub token from Google/YouTube API is always returned as invalid
原标题:

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
问题回答

ClientLogin does not return AuthSub tokens. They are unrelated.

Try Authorization: GoogleLogin auth="AUTHORIZATION_KEY"

instead of Authorization: AuthSub token="AUTHORIZATION_KEY"

for ClientLogin





相关问题
get atom feed and display in html (google-api)

Can someone help me out on this. I have a problem with the return results from an google-api call I want to echo them back as html, but firefox keeps displaying a feed page. In IE, I get an error ...

Using Google App Engine With My Dreamhost Registered Domain

I have registered a domain example.com using dreamhost, and currently have a standard wordpress blog set up on www.example.com. I d like to have appengine.example.com point to my Google Appengine ...

google calendar java api

I have an object of CalendarEntry I know that http://www.google.com/calendar/feeds/example@gmail.com/allcalendars/full is the feed url of all calendars but how I can get this feed url from ...

Google API for Internationalization + asp.net

Hai guys, Is there any google api for Internationalization with asp.net or any other open source api for it because i want my users to view my site in multiple indian languages like tamil,malayalam,...

google API translate, only a div into page

I have an HTML page, and I would use Google Translate to translate only a div into my page. <div id="google_translate_element"></div><script> function googleTranslateElementInit() { ...

How to use doctest on a Client script?

I am playing with Google Calendar API, creating some useful function. I another hand, I want to do it right puting some useful doctest and starting agile development. How to write doctest since the ...

using google.loader.ClientLocation

what will be best way to use using google.loader.ClientLocation to get client country & city name in jquery Thanks

热门标签