Google登录API OAuth2-错误:invalid_request [英] Google Sign In API OAuth2- Error: invalid_request

查看:544
本文介绍了Google登录API OAuth2-错误:invalid_request的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用Google登录API时遇到问题.我按照教程进行了配置,并从Google Dev中进行了配置.安慰.看起来很简单...我在Stack Overflow上读到了类似的问题,但我能找到的就是:添加您的授权来源...(顺便问一下授权来源"是什么?)

I am having problems with the google Sign In API. I followed the tutorial to configure it from the Google Dev. console. Looked pretty simple... I read some similar questions on Stack Overflow, but all I could find is : Add your authorized origins... (By the way what is the 'Authorized origins' ?)

这是我插入到PHP网页中的代码:

Here is the code I inserted into my PHP web page :

<head>
  <title>CrateBoxStudio</title>
  <meta name="google-signin-client_id" content="**MYCODE**-nk3amkhq4disgfjmcsd53gku38bk6rpv.apps.googleusercontent.com">
  <script src="https://apis.google.com/js/platform.js" async defer></script>
</head>

我没有在上面的代码中包含按钮和javacript函数,因为我认为这对我的问题并不重要.我还排除了boostrap和jQuery的东西以及其他不相关的标签.

I did not include the button and the javacript functions in the above code, as I think it is not important for my problem. I also excluded boostrap and jQuery stuff and other unrelated tags.

The error simple description : Permission denied to generate login hint for target domain.

完整的错误详细信息(请求的详细信息):

Full error detail (Requested details):

redirect_uri=storagerelay://http/192.168.0.111?id=auth885739
response_type=permission id_token
scope=email profile openid
openid.realm=
client_id=**MYCODE**-nk3amkhq4disgfjmcsd53gku38bk6rpv.apps.googleusercontent.com
ss_domain=http://192.168.0.111
fetch_basic_profile=true
gsiwebsdk=2

192.168.0.111是我的服务器的本地IP.这是我的服务器本地IP,因为我正在本地对其进行测试.如果它是在我家外访问的,那将是我的路由器IP. (我们不能在授权来源中使用数字IP,这可能相关吗?)

192.168.0.111 is the local IP of my server. It is my server local IP because I am testing it locally. It would be my router IP if it was accessed outside my home. (We can't use numeric IPs in the Authorized origins, could this be related?)

以上是我单击网站主页上的登录"按钮时遇到的错误(目前只有1个页面,index.php) 自己看看: http://crateboxstudio.com (此URL已从Google控制台添加到Authorized JavaScript起源中.该网址将我们带到我的index.php页面.)

Above is the error I get when I click the Sign in button on my website home page (I only have 1 page for now, index.php) See by yourself : http://crateboxstudio.com (This URL was added to the Authorized JavaScript origins from the Google Console. The URL brings us to my index.php page.).

所以

此域名由GoDaddy托管.

This domain name is hosted by GoDaddy.

我的服务器在带有Ubuntu Server的Apache2上运行.

My server is running on Apache2 with Ubuntu Server.

Google登录按钮将引发以上错误

The Google sign in button throws the error above

我只有1页(index.php).这是登录"按钮所在的位置.

I only have 1 page (index.php). It is where the Sign in button is.

我的域名重定向到端口8080上的路由器IP,该URL被URL隐藏.

My domain name redirects to my router IP on port 8080, hidden by the URL.

我将crateboxstudio.com和lan.crateboxstudio.com添加到了控制台中域验证的允许域中.

I added crateboxstudio.com and lan.crateboxstudio.com to the allowed domains of the Domain verificatiion in the console.

除了上面提到的,我什么也没做.

I did nothing else than what is mentioned above.

JavaScript授权来源:

Authorized JavaScript origins :

http://www.lan.crateboxstudio.com (事实如此我可以在家使用子域)

http://www.lan.crateboxstudio.com (This is just so I can use a subdomain at home)

授权的重定向URI: -没事...

Authorized redirect URIs: -Nothing...

任何人都知道如何获取有关错误的更多信息或如何解决该错误的信息?

Anyone has an idea how I could get more info about my error or how to fix it?

P.S.我对堆栈溢出的问题不太熟悉,如果我不遵守某些标准,请原谅.随时发表评论.

P.S. I am not much familiar with questions on stack overflow, excuse me if I do not respect some standard. Feel free to comment.

谢谢你, 板条箱

推荐答案

毕竟,我发现goDaddy域名配置存在问题.我切换到Google Domain(为了简化起见,界面是如此简洁明了),我发现我试图将我的域转发到服务器IP.

After all, I found out there was a problem with my goDaddy domain name configuration. I switched to Google Domain (to make things simpler, the interface is so clear and simple) and I figured out that I was trying to forward my domain to my server IP.

这是不正确的.该API不支持转发域.它必须是A记录(或者我可能对此不太了解)

This is incorrect. The API does not support forwarded domain. It had to be a A record (Or whatever type maybe I don't know much about these)

我在Google Domains中的域设置:

My domain settings from Google Domains:

在上面的图片中,我创建了2 A(或者可能是什么类型,我对此不太了解)记录. @(当前域名的缩写,又名crateboxstudio.com)用于我的公共IP.

In the picture above, I created 2 A (or whatever types maybe, I don't know much about these) records. The @ (shortcut for the current domain name, AKA crateboxstudio.com) is for my public IP.

第二个局域网(lan)是我进行本地测试的子域(lan.crateboxstudio.com).

The second, lan, is my subdomain for local testing (lan.crateboxstudio.com).

带有蓝色大X的区域是goDaddy上的等效部分,我试图将我的域转发到某个IP.无法做到.但是不确定为什么.

The area with big blue X is the equivalent section on goDaddy where I was trying to forward my domain to a certain IP. Couldn't do that... Not sure why however.

我在Google API控制台中的凭据设置:

My credential settings from Google API Console:

上图中需要www和非www.

The www and the not www are required in the picture above.

最后效果很好!但是,我的ISP阻止了端口80,所以我不能只键入crateboxstudio.com,而是需要键入crateboxstudio.com:8080 ...

Works well finally! However, my ISP blocks port 80, so I can't just type crateboxstudio.com, I need to type crateboxstudio.com:8080...

这篇关于Google登录API OAuth2-错误:invalid_request的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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