如何处理任意数量的重定向URI? [英] How to deal with arbitrary amount of redirect URIs?

查看:49
本文介绍了如何处理任意数量的重定向URI?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个应用程序,其中用户拥有自己的URL,他们需要使用Google API-当然要使用不同的重定向URI,例如

I'm developing an application where the users have their own URLs, and they need to use Google API - of course with different redirect URIs, like

  • www.example.com/johndoe/google/login
  • www.example.com/foobar/google/login

因此,首先我想我可以通过使用通配符(www.example.com/*/google/login)来解决此问题,但是不幸的是,这种方式不起作用.然后,我开始在Perl中编写一个简单的代理,但是我不确定它是否可以正常工作,并且我们的时间已经用完了.处理这种情况的最佳方法是什么?我曾考虑过从注册处理程序向控制台添加新的重定向URI,但是我找不到服务器可以执行此操作的任何方式.

So first I thought I could simply solve this problem by using wildcards (www.example.com/*/google/login), but it unfortunately doesn't work that way. Then I started to code a simple proxy in Perl, but I'm not sure it would work and we're running out of time. What is the best way to deal with the situation? I thought about adding a new redirect URI to the console from the registration handler, but I didn't find any way the server could do this.

推荐答案

Google OAuth2重定向URI不支持通配符.我认为最好的办法是使用单个重定向URI,并在state参数中传递用户信息.作为响应,状态参数将返回给您.然后,当您收到授权码/令牌时,您可以查找state参数并适当地处理响应(例如,重定向到用户特定的URL).

Wildcards are not supported in Google OAuth2 redirect URIs. I think your best best is to use a single redirect URI, and pass in the user information in the state parameter. The state parameter is returned to you in response. Then, when you receive the authorization code/tokens, you can lookup the state parameter and handle the response appropriately (e.g., redirect to your user-specific URLs).

此答案具有更多信息.

这篇关于如何处理任意数量的重定向URI?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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