Google API - 如何将网址重定向到我的本地主机 [英] Google API - How to redirect URL to my localhost

查看:787
本文介绍了Google API - 如何将网址重定向到我的本地主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Google OAuth在我的Phonegap应用中集成google登录。会发生什么,当我创建我的应用程序的客户端ID,我必须选择安装应用程序,然后应用程序类型为其他,因为我使用Phonegap创建我的应用程序。

I am working on integrating google login in my Phonegap app using Google OAuth. What happens is that while creating a client ID for my app, I have to choose "Installed Application" and then the application type as "Others" since I am creating my app using Phonegap.

这给我两个重定向URI,如 urn:ietf:wg:oauth:2.0:oob http:// localhost 。我不选择用 urn:ietf:wg:oauth:2.0:oob ,因为它要求用户复制代码,并把它放回到应用程序。我有另一个选项是重定向到本地主机。

This gives me two redirect URIs such as "urn:ietf:wg:oauth:2.0:oob" and "http://localhost". I am not opting to go with "urn:ietf:wg:oauth:2.0:oob" as it requires the user to copy the code and put it back to the app. The other option that I have is redirecting to localhost.

这里的问题是,当我在iPad上时,如何将URL重定向到localhost?我尝试使用不同的重定向URI,但Google不允许我使用它们。它坚持只有重定向到localhost(或添加一些端口号),我没有别的去。

Here the problem is that how do I redirect the URL to localhost when I am on iPad? I have tried to use different redirect URIs but Google doesn't let me use them. It sticks only with redirecting to localhost (or adding some port numbers) which I have no other go.

有没有人有任何解决方法?有任何方法来完成这个任务吗?我被卡住了。请帮忙。

Does anyone have any workaround on this? Are there any methods to accomplish this task? I am stuck. Please help.

推荐答案

也可以使用重写规则。

我需要Google的回调函数: http://local.dev/users/login-google

For example, I need this callback for Google : http://local.dev/users/login-google

已在Google控制台中设置此网址: http://localhost/JUMP/local.dev/users/login-google

So I have set this URL in Google Console : http://localhost/JUMP/local.dev/users/login-google

在apache中,一个简单的重定向:

And in apache, a simple redirect :

RewriteEngine  on
RewriteRule    ^JUMP/(.+)$   http://$1 [R,L]

这篇关于Google API - 如何将网址重定向到我的本地主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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