被阻止的滥用用户的正确 HTTP 状态代码是什么?

What's the right HTTP Status code for a blocked, abusive user?

我正在构建一个应用程序,用户可能会因为使用攻击性语言而被屏蔽。当用户被阻止时,他或她的应用无法访问某些 API 调用。

应该怎么选才对HTTP status code when a blocked user tried access these API parts? Error 403好像是个不错的选择,但是不知道有没有更具体的。

只是为了完整性....

问题的答案是没有其他代码比 403(明显)更合适。正如维基百科所说:

"HTTP 403 is returned when the client is not permitted access to the resource despite providing authentication - either because authentication failed, or for some reason besides authentication, such as insufficient permissions of the authenticated account. This other reason needs to be acted upon before re-requesting access to the resource."

这很符合您描述的场景。

另一件事是,由于您已经阻止了用户,您可能不在乎他们如何看待状态代码的“正确性”。没有其他人会关心这种或那种方式。

最终是你的选择。