gpt4 book ai didi

rest - 已验证但未授权的 HTTP 状态代码?

转载 作者:可可西里 更新时间:2023-11-01 17:06:31 27 4
gpt4 key购买 nike

如果请求经过身份验证(根据 The OAuth 2.0 Authorization Framework: Bearer Token Usage: Authorization Request Header Field )但经过身份验证的用户无权查看所请求的资源,REST API 应使用哪个 HTTP 状态代码响应?

例如,假设我请求查看某个用户的个人资料:GET/users/123。我验证成功,但该用户已阻止我。服务器应响应哪个 HTTP 状态码?

相关:

最佳答案

你需要的代码是403 Forbidden:

来自 wikipedia :

A 403 response generally indicates one of two conditions:

  • Authentication was provided, but the authenticated user is not permitted to perform the requested operation.
  • The operation is forbidden to all users. For example, requests for a directory listing return code 403 when directory listing has been disabled.

关于rest - 已验证但未授权的 HTTP 状态代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39156166/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com