How do I add “authorized redirect URIs” to Google OAuth2 using an API?

时间秒杀一切 提交于 2019-12-04 18:53:12

问题


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.

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

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.

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?


回答1:


You can't, unfortunately.

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. 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


来源:https://stackoverflow.com/questions/31330824/how-do-i-add-authorized-redirect-uris-to-google-oauth2-using-an-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!