tool::http-status-detail
401 Unauthorized
Authentication is required and has failed or not been provided.
ステータスコード
401
名前
Unauthorized
カテゴリ
4xx詳細説明
HTTP 401 Unauthorizedは、リクエストに有効な認証情報が含まれていないことを示します。名前は「Unauthorized」ですが、実際には認証(Authentication)の失敗を意味します。サーバーはこのレスポンスとともにWWW-Authenticateヘッダーを送信し、どの認証方式を使用すべきかを通知します。403 Forbiddenと混同しやすいですが、401は「誰か分からない」、403は「誰かは分かるが権限がない」という意味です。
主な原因
- ▸認証トークン(Bearer、JWTなど)がリクエストヘッダーに含まれていない場合
- ▸トークンが期限切れまたは無効な場合
- ▸ユーザー名/パスワードの組み合わせが間違っている場合
- ▸APIキーが間違っているか無効化されている場合
解決方法
- 1.Authorizationヘッダーに正しいトークンが含まれているか確認してください
- 2.トークンが期限切れの場合はrefresh tokenで新しいトークンを取得してください
- 3.APIキーが有効でアクティブな状態か確認してください
- 4.認証方式(Basic、Bearer、API Key)がサーバーの要件と一致しているか確認してください
関連HTTPヘッダー
WWW-AuthenticateAuthorizationProxy-Authenticateレスポンス例
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer realm="api"
Content-Type: application/json
{"error":"invalid_token","message":"Token has expired"}関連ステータスコード
400Bad RequestThe server could not understand the request due to invalid syntax.→402Payment RequiredReserved for future use; some services use it for payment walls.→403ForbiddenThe server refuses to fulfill the request (authenticated but unauthorized).→404Not FoundThe requested resource could not be found.→405Method Not AllowedThe HTTP method is not supported for this resource.→
ad · 300×250
// related tools