L
longredhao

  • 2024年9月16日
  • 注册于 2024年9月1日
  • 0 次助人
  • halo小白用户

  • 背景:
    通过api 想生成文章和发布文章,当访问列出post的API时,报403错误。
    接口中已经输入了授权码 Bearer 的 key,

    通过 halo的swagger 访问接口:
    http://IP:9088/webjars/swagger-ui/index.html#/PostV1alpha1Uc/ListMyPosts
    报 403 错误,显示未授权。
    用 curl 命令访问也是报403:

    curl -X 'GET' \
      'http://IP:9088/apis/uc.api.content.halo.run/v1alpha1/posts?page=0&size=1&sort=string' \
      -H 'accept: */*' \
      -H 'Authorization: Bearer pat_XXXXXX'

    返回:
    `
    Code Details
    403
    Error: Forbidden

    Response headers
    cache-control: no-cache,no-store,max-age=0,must-revalidate
    connection: keep-alive
    content-length: 0
    expires: 0
    keep-alive: timeout=4
    pragma: no-cache
    proxy-connection: keep-alive
    referrer-policy: strict-origin-when-cross-origin
    vary: Origin,Access-Control-Request-Method,Access-Control-Request-Headers
    www-authenticate: Bearer error="insufficient_scope",error_description="The request requires higher privileges than provided by the access token.",error_uri="https://tools.ietf.org/html/rfc6750#section-3.1"
    x-content-type-options: nosniff
    x-frame-options: SAMEORIGIN
    x-xss-protection: 0
    `
    请问 是哪里的问题? 我怎么访问API 才能正确 list post 和 create post ?