The most direct way to use an API key is to pass it in the X-JFrog-Art-Api header. This avoids including credentials in the URL or using standard Authorization headers that might be reserved for other proxies.
You can also use your API key as a replacement for your password in a standard Basic Auth request.
If you are moving away from API keys, you can use an as a Bearer Token in your download commands:
curl -H "Authorization: Bearer " -L -O "https://url-to-artifact" ``` ### Key Best Practices * **Use JFrog CLI:** For high-performance downloads, use the [JFrog CLI](https://jfrog.com) (`jf rt dl`), which supports parallel downloads and handles authentication automatically once configured. * **Avoid API Keys in URLs:** While some APIs allow `?key=...` in the URL, this is insecure as it exposes the key in logs and browser history. * **Use Reference Tokens:** If your legacy tools require short credentials, [Reference Tokens](https://jfrog.com/help/r/platform-api-key-deprecation-and-the-new-reference-tokens/why-should-i-use-reference-tokens) are a 64-character alternative that works exactly like an API key but with better security management. Would you like a specific script to **automate downloads** for multiple files or to **migrate** your existing API key workflows to access tokens? Use code with caution.
Artifactory Download with API Key: A Complete Guide Downloading artifacts from via its REST API is a standard practice for automating CI/CD pipelines and DevOps workflows. While username/password authentication was common in the past, using an API Key or the newer Access Token provides a more secure and programmatic way to manage downloads. How to Download Using an API Key
import requests url = "https://jfrog.io" headers = {"X-JFrog-Art-Api": "YOUR_API_KEY"} response = requests.get(url, headers=headers) with open("app.jar", "wb") as f: f.write(response.content) ``` Use code with caution.
It is critical to note that JFrog has in favor of more modern and secure authentication methods like Access Tokens and Reference Tokens . Access/Reference Token Lifecycle Manual revocation only Can have a set expiry date Scope Tied to a specific user Can be scoped to groups or projects Security Static and long-lived Safer for CI/CD with short-lived options Transitioning to Access Tokens
-L : Follows any redirects if the file has moved or is in a virtual repository. -O : Saves the file using its original name from the URL. 2. Using Basic Authentication
curl -H "X-JFrog-Art-Api: " \ -L -O "https:// .jfrog.io/artifactory/ /path/to/artifact.ext" Use code with caution. -H : Sets the custom header with your API key.
curl -u : -O "https:// .jfrog.io/artifactory/ /file.zip" Use code with caution. Automation Examples