static HttpResponse unauthorized(@Nullable String errorType, @Nullable String accessTokenType,
                                     @Nullable String realm, @Nullable String scope) {
        final Map<String, String> errorFieldsMap = new LinkedHashMap<>(3);
        if (realm != null) {
            errorFieldsMap.put(REALM, realm);
        }
        if (errorType != null) {
            errorFieldsMap.put(ERROR, errorType);
        }
        if (scope != null && !scope.isEmpty()) {
            errorFieldsMap.put(SCOPE, scope);
        }
        final String errorFields = errorFieldsMap.entrySet().stream()
                                                 .map(e -> e.getKey() + "=\"" + e.getValue() + '"')
                                                 .collect(Collectors.joining(", "));
        final String wwwAuthenticateType = accessTokenType == null ? BEARER : accessTokenType;
        final String wwwAuthenticate = errorFields.isEmpty() ?
                wwwAuthenticateType : String.join(" ", wwwAuthenticateType, errorFields);
        final ResponseHeaders responseHeaders =
                ResponseHeaders.of(HttpStatus.UNAUTHORIZED,
                                   HttpHeaderNames.WWW_AUTHENTICATE, wwwAuthenticate);
        return HttpResponse.of(responseHeaders);
    }
E.g.
   invalid_token
         <p>The access token provided is expired, revoked, malformed, or
         invalid for other reasons. The resource SHOULD respond with
         the HTTP 401 (Unauthorized) status code. The client MAY
         request a new access token and retry the protected resource
         request.</p>
         Example:
         <pre>{@code
             HTTP/1.1 401 Unauthorized
             WWW-Authenticate: Bearer realm="example",
                               error="invalid_token",
                               scope="read write"
         }</pre>
oauth2/src/main/java/com/linecorp/armeria/server/auth/oauth2/OAuth2AuthorizationErrorReporter.java