2012-01-03 74 views

回答

0

已安裝的應用程序嘗試的OAuth 2.0:http://code.google.com/apis/youtube/2.0/developers_guide_protocol.html#OAuth2_Installed_Applications_Flow

首先,註冊API獲得的client_id。

然後,請合作伙伴登錄他們的谷歌帳戶,輸入以下URL,更改您的client_id。 redirect_uri應設置爲「urn:ietf:wg:oauth:2.0:oob」。

https://accounts.google.com/o/oauth2/auth?client_id=1084945748469-eg34imk572gdhu83gj5p0an9fut6urp5.apps.googleusercontent.com&redirect_uri=urn:ietf:wg:oauth:2.0:oob&scope=https://gdata.youtube.com&response_type=code&access_type=offline

然後他們授權你的應用程序,並得到一個授權碼。

然後打開終端和類型(更改代碼,CLIENT_ID和client_secret):

curl https://accounts.google.com/o/oauth2/token -d "code=4/ux5gNj-_mIu4DOD_gNZdjX9EtOFf&client_id=1084945748469-eg34imk572gdhu83gj5p0an9fut6urp5.apps.googleusercontent.com&client_secret=hDBmMRhz7eJRsM9Z2q1oFBSe&redirect_uri=urn:ietf:wg:oauth:2.0:oob&grant_type=authorization_code" 

你會得到響應,如:

{ "access_token" : "ya29.AHES6ZTtm7SuokEB-RGtbBty9IIlNiP9-eNMMQKtXdMP3sfjL1Fc", "token_type" : "Bearer", "expires_in" : 3600, "refresh_token" : "1/HKSmLFXzqP0leUihZp2xUt3-5wkU7Gmu2Os_eBnzw74" }

記住refresh_token,每一次你運行你的應用程序,你需要用refresh_token獲得一個新的access_token。

相關問題