showdoc icon indicating copy to clipboard operation
showdoc copied to clipboard

oauth2登录无法获取用户信息问题

Open awen112 opened this issue 11 months ago • 17 comments

howdoc在配置oauth2登录完成后,进行单点登录无法获取用户信息,该如何配置? 521735617277_ pic WX20241231-144730@2x

awen112 avatar Dec 31 '24 07:12 awen112

那个 获取用户信息的接口 user info path , 你确定这个接口可以返回用户信息吗

star7th avatar Dec 31 '24 07:12 star7th

那个 获取用户信息的接口 user info path , 你确定这个接口可以返回用户信息吗

可以返回

awen112 avatar Dec 31 '24 07:12 awen112

返回的数据是怎样的

star7th avatar Dec 31 '24 07:12 star7th

另外这个是最新版showdoc吗,如何安装的

star7th avatar Dec 31 '24 07:12 star7th

返回的数据是怎样的

{ "sub": "x'x'x'x'x", "email_verified": true, "phone_number_verified": false, "preferred_username": "xxxxxxx", "picture": "xxxxxx", "updated_at": "xxxxxxxx", "nickname": "", "phone_number": "", "email": "xxxxxxx" }

awen112 avatar Dec 31 '24 07:12 awen112

另外这个是最新版showdoc吗,如何安装的

最新版,一键部署安装的

awen112 avatar Dec 31 '24 07:12 awen112

showdoc请求用户信息接口的时候, 其 认证用的access_token 既放到了header中,也放在url的参数中.据我所知, 少部分接口是不能同时用这两种方式.你确认下你的这个用户信息接口, access_token 是放在什么位置的

star7th avatar Dec 31 '24 08:12 star7th

我说的问题,跟这个类似 https://github.com/star7th/showdoc/issues/2102 接口应该支持两种认证方式的

star7th avatar Dec 31 '24 08:12 star7th

showdoc请求用户信息接口的时候, 其 认证用的access_token 既放到了header中,也放在url的参数中.据我所知, 少部分接口是不能同时用这两种方式.你确认下你的这个用户信息接口, access_token 是放在什么位置的

在url中

awen112 avatar Dec 31 '24 08:12 awen112

你上面的报错,意思是接口获取不到任何结果. 获取不到你给出的json数据. 获取不到任何结果的可能性很多, url错了,协议错了,服务器安全限制 等等

star7th avatar Dec 31 '24 08:12 star7th

不应该获取不到任何结果的.假如认证错误,起码应该报个错.我还是觉得你的url写错了.你尝试把host也写上,写完整的url

star7th avatar Dec 31 '24 08:12 star7th

https://topiam.cn/docs/use-cases/application/showdoc-oidc/ TOPIAM 使用OIDC协议集成的 showdoc,topiam使用的是OIDC协议,返回字段应该是preferred_username。这篇文章建议作者可以加入到文章站中。

leshalv avatar Jan 01 '25 11:01 leshalv

showdoc 兼容用户字段是多种场景,比如 preferred_username , username ,name 。 就上面的情况而言,不是字段不对的问题,是请求用户接口就错误的问题。

smallbun @.***>于2025年1月1日 周三下午7:19写道:

https://topiam.cn/docs/use-cases/application/showdoc-oidc/ TOPIAM 使用OIDC协议集成的 showdoc,topiam使用的是OIDC协议,返回字段应该是preferred_username。这篇文章建议作者可以加入到文章站中。

— Reply to this email directly, view it on GitHub https://github.com/star7th/showdoc/issues/2313#issuecomment-2566964546, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQZHLRII7QENZYDJV5CC432IPFLZAVCNFSM6AAAAABUNC6C6GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNRWHE3DINJUGY . You are receiving this because you commented.Message ID: @.***>

star7th avatar Jan 01 '25 11:01 star7th

遇到相同的问题,获取用户信息的接口 user info path 本地测试是可以返回数据

不应该获取不到任何结果的.假如认证错误,起码应该报个错.我还是觉得你的url写错了.你尝试把host也写上,写完整的url

能否在 else { echo "登录成功但无法获取用户信息"; } 分支里面增加打印 $res 方便排查

alewu avatar Aug 18 '25 07:08 alewu

更新了,打印 $res 方便排查

star7th avatar Aug 18 '25 14:08 star7th

更新了,打印 $res 方便排查

Image

像这种提示为空的是啥问题

alewu avatar Aug 29 '25 10:08 alewu

提示为空,那就是目标服务器返回是空。可能是目标服务器的安全限制等原因。

star7th avatar Sep 01 '25 02:09 star7th