简体   繁体   English

SonarQube api api/project_analyses/search 失败并显示 403“msg”:“权限不足”但 API 关键用户是管理员

[英]SonarQube api api/project_analyses/search fails with 403 "msg": "Insufficient privileges" yet API key user is admin

I am accessing the SonarQube API through API key as described in https://docs.sonarqube.org/latest/extension-guide/web-api/我正在访问 SonarQube API 到 API 密钥,如https://docs.sonarqube.org/latest/extension-guide/web-api/中所述

  • A call to /api/components/search_projects works.调用 /api/components/search_projects 有效。
  • A call to /api/project_analyses/search?project=PJ fails with http error code 403调用/api/project_analyses/search?project=PJ失败,错误代码为 http 403

If I log into the web interface with that user, I can browse the statistics.如果我用那个用户登录到 web 界面,我可以浏览统计信息。 In fact Chromes F12 debug shows that it's calling the same api function /api/project_analyses/search yet with session cookie, xrfs-token etc. and the call succeeds.事实上,Chromes F12 调试显示它正在调用相同的 api function /api/project_analyses/search和 session cookie、xrfs-token 等,并且调用成功。

What am I missing to be able to retrieve project statistics through the API?我缺少什么才能通过 API 检索项目统计信息?

The token used is created by the user which has sufficient permission for the project PJ使用的令牌由对项目PJ具有足够权限的用户创建

You need to check the permission and generate new token accordingly.您需要检查权限并相应地生成新令牌。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM