/admin/users/1/log_out route error

Am getting this error when trying to log out user via the sso logout endpoint both on postman and on the site.

Production logs say there is a route error. Have double checked that the api username and key are correct. Am able to get the same code to work on development env but not in production.

Have tried revoking and re-creating the api key several times to no avail. Have tried both putting params in header and sending them as query params as well.

Here is the production log output:

Started POST β€œ/admin/users/2/log_out?api_username=dev&api_key=[FILTERED]” for 73.71.125.29 at 2020-05-26 01:37:17 +0000
ActionController::RoutingError (No route matches [POST] β€œ/admin/users/2/log_out”)

Does something special need to be done to have the api key picked up in production?

You need to set the Api-Key and Api-Username in the request headers. Have a look at the curl example that’s near the top of this topic: Discourse API Documentation. Make sure to use a dash (-) and not an underscore (_) for the field names. For example api-key will work for the field name, api_key will not work.

2 Likes

That worked, thanks.

If anyone else is having this problem- here is the curl command you need for testing:

curl -X POST "http://localhost:3000/admin/users/1/log_out" \
-H "Content-Type: multipart/form-data;" \
-H "Api-Key: [FILTERED]" \
-H "Api-Username: system"
1 Like