fief-dev / fief

Users and authentication management SaaS
https://www.fief.dev
Other
488 stars 42 forks source link

"Internal Server Error" when login to Fief in browser after HTTP/PATCH via REST API #194

Closed Kh-Oleg closed 1 year ago

Kh-Oleg commented 1 year ago

Describe the bug

When I try to login to Fief in browser after modifying the Fief's client via Admin REST API, I see "Internal Server Error" in the browser.

To Reproduce

Steps to reproduce the behavior:

  1. Start Fief with the initial Admin Key
  2. Go to /admin/api/docs
  3. Authorize with the Admin Key
  4. Execute GET /clients/ to see the parameters of the existing client, it's "Fief's client"
  5. Go to PATCH /clients/{id}
  6. Enter id from the step 4 to the id's field
  7. Enter redirect URIs from the step 4 to the PATCH payload
  8. Enter client name from the step 4
  9. Execute the request, you should get 200 OK and a valid response body
  10. Now open browser and open Fief's admin page, /admin
  11. Fief will ask to login
  12. After entering the admin's credentials, browser shows "Internal Server Error"

Expected behavior

A Fief dashboard shall be shown after a successful login.

Configuration

Additional context

Fief doesn't print any call stack to console in this case.

Kh-Oleg commented 1 year ago

Additional info: the exception fief_client.client.FiefRequestError happens in the file ./fief/apps/dashboard/routers/auth.py, method

@router.get("/callback", name="dashboard.auth:callback")
async def callback(.....)

at the line:
tokens, userinfo = await fief.auth_callback(
  code, str(request.url_for("dashboard.auth:callback"))

The exception's message is '[400] - {"error":"invalid_grant"}'