的OAuth 2.0分发Web应用程序 [英] OAuth 2.0 for distributable web applications

查看:160
本文介绍了的OAuth 2.0分发Web应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想弄清楚,如何使用OAuth 2.0,从我的web应用程序访问谷歌的API。问题是,该协议要求开发者注册的 REDIRECT_URI (接收页面访问令牌的URL)。但是,我的应用程序可以分布到很多客户,并可以在服务器上的数不完主办。有没有办法知道的 REDIRECT_URI 事先

I'm trying to figure out, how to use OAuth 2.0 to access Google APIs from my web app. The problem is, that the protocol require developer to register redirect_uri (URL of page receiving access token). But my application can be distributed to many customers and can be hosted on endless number of servers. There is no way to know redirect_uri beforehand.

谷歌提供了安装的应用程序的另一种选择,但我不能用这种变异没有。验证服务器窗口标题返回访问code和本信息不能从我们的页面的JavaScript访问(JS不能访问窗口的内容使用window.open()打开;如果内容来自于不同的服务器)。

Google offers another option for installed applications, but I cannot use this variant neither. Auth server returns access code in window title and this information cannot be accessed from javascript of our page (JS cannot access content of window opened using window.open(); if that content comes from different server).

要总结:


  1. 无法为Web应用程序使用的方法,因为我不知道所有的URL地址将在我们未来的应用程序运行。

  2. 无法使用方法安装的应用程序,因为窗口标题是不是从我们的JavaScript code访问。

有任何建议,如何使用谷歌的OAuth 2.0从分配网络上的许多服务器运行的应用程序?谢谢你。

Is there any recommendation, how to use Google's OAuth 2.0 from distributable web application running on a lots of servers? Thank you.

推荐答案

你确定你不能访问窗口标题?如果您的应用程序打开的窗口,它应该能够访问它。它应该能够做到这一点,你会做一个移动应用程序类似的方式。

Are you sure you cannot access the window title? If your app is opening the window, it should be able to access it. It should be possible to do this in a similar way you would do it in a mobile app.

如果所有的尝试都失败,你可以设置一个代理服务器(具有已知重定向URI)和手出谷歌令牌给所有客户。或者更好的每一个应用程序可能有自己的代理服务器 - 它是从下载服务器。不过,如果每个OAuth用户端只能有一个重定向URI,每个应用程序必须是一个单独的OAuth客户端。

If all attempts fail, you could set up a proxy server (that has a known redirect URI) and hands out the Google tokens to all your clients. Or better each of the apps could have its own proxy server - the server it was downloaded from. But then if each OAuth client can only have one redirect URI, each app would have to be a separate OAuth client.

这篇关于的OAuth 2.0分发Web应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆