我正在为一些不属于我自己的YouTube频道开发软件。
要检索洞察数据,我需要通过身份验证。如何做到这一点呢?
发布于 2012-01-16 13:14:43
在已安装的应用程序中试用OAuth 2.0:http://code.google.com/apis/youtube/2.0/developers_guide_protocol.html#OAuth2_Installed_Applications_Flow
首先,注册接口获取client_id。
然后,要求合作伙伴登录到他们的谷歌帐户,键入以下网址,更改client_id与您的。redirect_uri应该设置为"urn:ietf:wg:oauth:2.0:oob“。
然后他们授权你的应用程序,并得到一个授权码。
然后打开终端并输入(更改您的代码、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。
https://stackoverflow.com/questions/8717825
复制相似问题