如何添加“授权重定向URI"?使用API​​访问Google OAuth2? [英] How do I add "authorized redirect URIs" to Google OAuth2 using an API?

查看:208
本文介绍了如何添加“授权重定向URI"?使用API​​访问Google OAuth2?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在试用Heroku的新"Heroku评论应用"功能.每当您在github中为给定项目创建新的拉取请求时,它都会创建一个新的Heroku App.

I'm trying out Heroku's new "Heroku Review Apps" feature. It creates a new Heroku App whenever you create a new pull request in github for a given project.

我正在尝试与他们一起使用Google OAuth2支持,但是每个创建的应用都有一个新的URL.例如 https://my-app-pr-124.herokuapp.com

I'm trying to get Google OAuth2 support working with them, but each created app has a new URL. e.g. https://my-app-pr-124.herokuapp.com

问题在于,当用户尝试登录此新应用时,Google不允许将用户重定向回该应用,因为Google尚不信任该URL.

The problem is that when a user tries to sign in on this new app, Google won't allow redirecting the user back to the app, since Google doesn't trust that URL yet.

我可以在我的应用程序中包含自己的Google API密钥,并在部署时运行脚本,但是如何通知Google应该信任此新URL进行重定向?

I can include my own Google API key with my app, and run a script on deploy, but how can I inform Google that this new URL should be trusted for redirects?

推荐答案

不幸的是,你不能.

您也许可以将它们从重定向代理(我叫这个名字)中弹起,以实现所需的功能.看起来像:-

You might be able to bounce them off a Redirect Proxy (I made that name up) to achieve what you want. It would look something like:-

  1. 声明重定向URL为 http://myredirectproxy.example.com
  2. http://myredirectproxy.example.com 上,您有一个简单的http服务器,该服务器以http 301进行响应到 https://my-app-pr-124.herokuapp.com
  1. Declare a redirect URL of http://myredirectproxy.example.com
  2. At http://myredirectproxy.example.com you have a simple http server which responds with an http 301 to https://my-app-pr-124.herokuapp.com

这篇关于如何添加“授权重定向URI"?使用API​​访问Google OAuth2?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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