programing

WordPress REST API의 403 "rest_forbidden" 오류(설정 전용)

golfzon 2023. 3. 20. 23:47
반응형

WordPress REST API의 403 "rest_forbidden" 오류(설정 전용)

WordPress에서 설정(/wp/v2/settings)을 제외한 모든 API를 받았습니다.rest_returning 오류입니다.

{
  "code": "rest_forbidden",
  "message": "Sorry, you are not allowed to do that.",
  "data": {
    "status": 403
  }
}

사용자에게 해당 경로의 데이터에 액세스할 수 있는 올바른 권한이 없습니다.개봉 즉시/settings/루트에는manage_options허가( 참조)get_item_permissions_check메서드).

// found in WP Core class-wp-rest-settings-controller.php
/**
 * Checks if a given request has access to read and manage settings.
 *
 * @since 4.7.0
 *
 * @param WP_REST_Request $request Full details about the request.
 * @return bool True if the request has read access for the item, otherwise false.
 */
public function get_item_permissions_check( $request ) {
  return current_user_can( 'manage_options' );
}

API 자격 증명과 관련된 사용자는 무엇입니까?

설정 엔드 포인트는 사용자가 가지고 있어야 합니다.manage_options사용 권한: 커스텀 역할을 사용하는 경우 를 사용하여 추가할 수 있습니다."manage_options" => true;

그렇지 않으면 사용자 관리자 역할만 수행합니다.

문제가 있는 경우는, https://wordpress.org/plugins/application-passwords/ 의 플러그 인을 참조하십시오.

프로파일에서 어플리케이션 비밀번호를 생성하여 기본 인증과 함께 사용하면 사용자 이름은 WordPress 사용자 이름 또는 이메일과 동일하며 비밀번호는 새로 생성된 비밀번호가 됩니다.

HTTP 헤더 개서 규칙을 .htaccess 파일에 추가해야 할 수도 있습니다.이것에 대해서는, https://github.com/WordPress/application-passwords/wiki/Basic-Authorization-Header----Missing 를 참조해 주세요.

언급URL : https://stackoverflow.com/questions/45931189/403-rest-forbidden-error-in-wordpress-rest-api-but-only-for-settings

반응형