CCMenu gives a 401 Unauthorized error

I’m using BuildNotify in order to get my CI results directly on my project, and would like to use it as well to track the results of the builds on a project hosted on my Gitea instance and using Drone CI.

Four years ago, it has been said that Drone supported CCMenu by giving an URL under the following form: http(s)://example.com/api/badge/github.com/{owner}/{repo}/cc.xml. Even though this URL seems to work if you remove the github.com part, on a private project it gives a 401 Unauthorized error to BuildNotify, because a session cookie is needed to access the resource. This behavior can be reproduced with a REST client like Insomnia or with cURL:

curl --request GET \
  --url https://example.com/api/badges/Me/Project/cc.xml \
  --cookie _session_=TheCookieValueHere

Is there any way to use the cc.xml route without any cookie on private projects?

Subsidiary suggestion: currently, the cc.xml route serves an XML content, but the Content-Type given by the server in HTTP headers is text/plain. It would be great for this header to be application/xml instead, just to fit the Web standards. :slight_smile:

You should use your API token to access restricted API endpoints [1]

curl --request GET \
- --url https://example.com/api/badges/Me/Project/cc.xml \
- --cookie _session_=TheCookieValueHere
+ -H "Authorization: Bearer AKIAIOSFODNN7EXAMPLE"
+ --url https://example.com/api/badges/Me/Project/cc.xml

Four years ago, it has been said that Drone supported CCMenu by giving an URL under the following form: http(s)://example.com/api/badge/github.com/{owner}/{repo}/cc.xml . Even though this URL seems to work if you remove the github.com part, on a private project it gives a 401

the information in that issue is outdated and the system has changed significantly in 4 years. You can find the ccmenu URL by navigating to your repository settings page, scroll to the bottom section labeled badges, and choose ccmenu from the dropdown.

[1] https://docs.drone.io/api/overview/

1 Like

Oh, I didn’t see this in the docs, thanks! :astonished: