logto
logto copied to clipboard
bug: Go Web: Integrate Logto , "Traditional web" Application , FetchTokenByAuthorizationCode responsed "invalid_client"
Describe the bug
Go Web: Integrate Logto , "Traditional web" Application , FetchTokenByAuthorizationCode responsed "invalid_client"
unexpected status code: 401, response body: {"error":"invalid_client","error_description":"client authentication failed"}
Expected behavior
"Traditional web" Application fail ,but use "Single Page App" is ok
How to reproduce?
Context
OS: CentOS Linux release 7.9.2009 (Core)
Environment: docker svhd/logto prerelease
Logto version: <= v1.0.0-beta.9 Node version: v16.17.0
Postgres version: 14.2
Command of starting Logto: docker
Screenshots
@xiaoyijun would you like to take a look? thanks
Hi, @dzp-java. Could you please provide a minimum reproduction repo for us? A related sample code is also welcomed.
@xiaoyijun Just according to the official instructions:
https://docs.logto.io/zh-cn/docs/recipes/integrate-logto/go-web
and "Single Page App" secret find by browser :
https://<logto-host>/api/applications/<appid>
Currently, the single-page application does not have an AppSecret
.
If you want to use the Go SDK in the single-page application, just remove the AppSecret
from the LogtoConfig
:
logtoConfig := &client.LogtoConfig{
Endpoint: "http://localhost:3001",
AppId: "someAppId",
Resources: []string{"someResource"},
}
By the way, if you're using a SPA, a client SDK ( React / Vue / Vanilla JS) is more suitable than a traditional web application SDK.
Actually, I use "Traditional web" Application at Go SDK ; but server response :
status code: 401, response body: {"error":"invalid_client","error_description":"client authentication failed"}
My guess is that there is a problem in judging the application type on the server side, not on the client side
This works well in our gin-sample; we need more information about your program. @dzp-java , would you like to provide a minimum reproduction repo for us?
I have a same problem.
logto'log shows 401 when a user sign in:
<-- GET /sign-in/consent
--> GET /sign-in/consent 200 9ms 220b
<-- GET /index.b4d7740b.css
<-- GET /api/.well-known/sign-in-exp
<-- GET /api/.well-known/phrases
<-- GET /index.d26ae494.js
--> GET /index.b4d7740b.css 200 63ms 5.09kb
--> GET /index.d26ae494.js 200 48ms 204.48kb
--> GET /api/.well-known/sign-in-exp 200 71ms 685b
--> GET /api/.well-known/phrases 200 73ms 1.47kb
<-- GET /favicon.ico
--> GET /favicon.ico 200 2ms 220b
<-- POST /api/interaction/consent
--> POST /api/interaction/consent 200 13ms 74b
<-- GET /oidc/auth/tQZOVnZlOLRG3UZAKbB6s
--> GET /oidc/auth/tQZOVnZlOLRG3UZAKbB6s 303 16ms 503b
<-- GET /oidc/.well-known/openid-configuration
--> GET /oidc/.well-known/openid-configuration 200 4ms 552b
<-- POST /oidc/token
--> POST /oidc/token 401 9ms 77b
I run it well on my localhost, but failed on cloud environment.
Could you please help me out? @xiaoyijun
@dzp-java Have you solved the problem?
I've come across the same problem too
I run gin-example against Traditional Web
application and it returns
unexpected status code: 401, response body: {"error":"invalid_client","error_description":"client authentication failed"}
I've come across the same problem too
I run gin-example against
Traditional Web
application and it returnsunexpected status code: 401, response body: {"error":"invalid_client","error_description":"client authentication failed"}
You can try to use this sdk: https://github.com/CloudNativeGame/logto-go
This is caused by obsolete Logto go module.
Check and update your go.mod manually, remove possibly:
github.com/logto-io/go/core // legacy obsolete module
github.com/logto-io/go/client // save as above
and replace them with:
github.com/logto-io/go v1.0.3
Then run go mod tidy
, everything should be fine.