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

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

问题描述

我在使用 google Sign In API 时遇到问题.我按照

有人知道我如何获得有关我的错误的更多信息或如何修复它吗?

附言我对堆栈溢出的问题不太熟悉,如果我不遵守某些标准,请见谅.欢迎发表评论.

谢谢,箱子

解决方案

毕竟,我发现我的 goDaddy 域名配置有问题.我切换到 Google Domain(为了让事情更简单,界面非常清晰和简单),我发现我试图将我的域转发到我的服务器 IP.

这是不正确的.API 不支持转发域.它必须是 A 记录(或者任何类型,也许我对这些不太了解)

来自 Google Domains 的我的域设置:

在上图中,我创建了 2 个 A(或任何类型,我对这些不太了解)记录.@(当前域名的快捷方式,AKA crateboxstudio.com)用于我的公共 IP.

第二个 lan 是我用于本地测试的子域 (lan.crateboxstudio.com).

带有大蓝色 X 的区域是 goDaddy 上我尝试将我的域转发到某个 IP 的等效部分.不能这样做...但不知道为什么.

来自 Google API 控制台的我的凭据设置:

上图中的 www 和非 www 是必需的.

终于成功了!但是,我的 ISP 阻止了端口 80,所以我不能只输入 crateboxstudio.com,我需要输入 crateboxstudio.com:8080...

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' ?)

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>

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 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?)

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

So,

This domain name is hosted by GoDaddy.

My server is running on Apache2 with Ubuntu Server.

The Google sign in button throws the error above

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

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

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.

Authorized JavaScript origins :

Authorized redirect URIs: -Nothing...

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

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.

Thank you, Cratebox

解决方案

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.

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)

My domain settings from Google Domains:

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.

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

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.

My credential settings from Google API Console:

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

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天全站免登陆