I am also trying to do this API scan with an API endpoint by using the CLI and generate a report. The command that was used is:
docker run -v {pwd}:/zap/wrk/:rw -t owasp/zap2docker-weekly zap-api-scan.py -t openapi.json -f openapi -z "-config /zap/wrk/options.prop" -r report_html.html
Above, in the openapi.json file, I passed my openapi definition and the options.prop file contains:
-config replacer.full_list(0).description=AuthHeader
-config replacer.full_list(0).enabled=true
-config replacer.full_list(0).matchtype=REQ_HEADER
-config replacer.full_list(0).matchstr=Authorization
-config replacer.full_list(0).regex=false
-config replacer.full_list(0).replacement=Bearer MyToken
Here, {pwd} was replaced with my directory and MyToken with the token received by a post request in Postman.
I have kept my openapi definition and the options.prop file in one directory (i.e., what I have passed as {pwd}), and as per what I understood, it gets mounted in the Docker image.
It generates the report as an output, but as I can see in the report, it does scan for those requests that do not require authentication, and for other endpoints that require authentication and where the scan should take place based on authentication, it is returning status codes of 404 and 403. I have attached the report for reference below
Can someone help me figure out what is going wrong and how I can correct it to perform an authenticated API scan?