将 Oauth 与 YouTube API 结合使用
我正在尝试添加 OAuth 身份验证以访问 YouTube,但如何添加 localhost 作为域?
例如,在域注册页面此处上,我想使用 localhost,因为我正在开发此应用程序本地。
帮助我或建议我其他方法
谢谢
请 我还在 https://webapps.stackexchange.com/ 上添加了这个问题,但不确定那里的社区活动,所以请忽略
I am trying to add OAuth athentication with to access YouTube, but how do I add localhost as domain?
For example on domain registration page here, I want to use localhost, since I am developing this application locally.
Please help me or suggest me alternative ways
Thank you
P.S. I also added this question on https://webapps.stackexchange.com/, but not sure about community activity there so please ignore
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
显然,您无法注册“localhost”进行身份验证,因为它只是一个别名。如果您想将 OAuth 与任何 Google 服务一起使用,则必须拥有一个域。如果您正在开发桌面应用程序,有一个解决方法(这实际上可能适用于所有人,但我没有尝试):
您实际上可以通过使用 HMAC-SHA1 创建签名来签署 OAuth 请求,而无需向 Google 注册您的域, “匿名”的消费者密钥和“匿名”的消费者秘密。只需确保您拥有适合您的请求的签名基本字符串即可。
http://code.google.com/apis/accounts/docs/OAuth_ref .html#SigningOAuth
Obviously you can't register 'localhost' for authentication since it is merely an alias. If you want to use OAuth with any Google service, you'll have to have a domain. If you're developing a desktop app, there is a workaround (this may actually work for all but I didn't try):
You can actually sign your OAuth requests without registering your domain with Google by creating a signature using HMAC-SHA1, a consumer key of "anonymous" and a consumer secret of "anonymous". Just make sure you have the appropriate signature base string for your requests.
http://code.google.com/apis/accounts/docs/OAuth_ref.html#SigningOAuth
在 Google API 控制台中为应用程序提供重定向 URI 的页面上,您可以使用 localhost。或者您可以在
/etc/hosts
文件中为 localhost 指定另一个名称,如下所示:On the page in Google's APIs console where you provide redirect URIs for your app, you can use localhost. Or you can give another name to localhost in your
/etc/hosts
file like this: