如何将凭据传递给 Sonar API 调用? [英] How do I pass credentials to Sonar API calls?

查看:25
本文介绍了如何将凭据传递给 Sonar API 调用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试打电话时:

https://sonar.mydomain.com/api/resources?resource=com.mydomain.project:MY&metrics=ncloc&format=json

我明白

{"err_code":401,"err_msg":"Unauthorized"}

我如何传递我的凭据?

推荐答案

根据 文档 SonarQube 使用基本身份验证.试试:

According to the documentation SonarQube uses basic authentication. Try:

curl -u admin:SuPeRsEcReT "https://sonar.mydomain.com/api/resources?resource=com.mydomain.project:MY&metrics=ncloc&format=json"

显然,传递这些凭据的机制取决于您调用 API 的方式.

Obviously the mechanism for passing these credentials is dependent on how you are invoking the API.

这也应该适用于网络浏览器.尝试登录 Webui,您的浏览器通常会缓存凭据.

This should also work from the web browser. Try logging into the Webui, your browser will normally cache the credentials.

这篇关于如何将凭据传递给 Sonar API 调用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆