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

查看:188
本文介绍了如何将凭证传递给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天全站免登陆