Get artifacts results page from command line

Context

Using Ruby, I’m trying to get the content of the last artifact that is a result of a SimpleCov coverage report.

I’m able so far to retrieve the last artifact with this code (using an Access Token) :

module Ci
  class Circle
    # more code

    def artifacts
      @artifacts = self.class.get("/project/github/#{@user}/#{@project}/latest/artifacts?circle-token=#{ENV['CI_ACCESS_TOKEN']}")
      self
    end

    # more code
  end
end

Then, I’m retrieving the index page which I want to get the content from, with this code:

def report
  artifacts = JSON.parse(@artifacts.parsed_response)
  artifacts.each do |response|
    url = response['url']
    return url if url.end_with? '.html'
  end
  nil
end

Problem

I want to get the content of the coverage page, located at https://3-57932222-gh.circle-artifacts.com/0//tmp/circle-artifacts.64VZY8w/coverage/index.html, but when logged out, it shows Must be log in. I’ve tried to check the CircleCI documentation but were not able to find out how to pass an access token to this page in order to get it’s content from the command line (where I’m obviously not log in). Ideas?

To make this work you can append an API token with ‘view-builds’ scope to the artifact link like so:

https://3-57932222-gh.circle-artifacts.com/0//tmp/circle-artifacts.64VZY8w/coverage/index.html?circle-token=YOUR_TOKEN_HERE

Generate a token on the ‘Project settings > API permissions’ screen.

@tom Thanks for your answer. I actually tried to do it but using the Api access token, not the project, which causes it to fails. Thanks again