     [Answers](https://scrapfly.io/blog)   /  [curl](https://scrapfly.io/blog/tag/curl)   /  [How to Set cURL Authentication - Full Examples Guide](https://scrapfly.io/blog/answers/how-to-set-authorization-with-curl-full-examples-guide)   

# How to Set cURL Authentication - Full Examples Guide

 by [Mazen Ramadan](https://scrapfly.io/blog/author/mazen) Nov 16, 2026 3 min read [\#curl](https://scrapfly.io/blog/tag/curl) 

 [  ](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-set-authorization-with-curl-full-examples-guide "Share on LinkedIn") [  ](https://x.com/intent/tweet?url=https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-set-authorization-with-curl-full-examples-guide&text=How%20to%20Set%20cURL%20Authentication%20-%20Full%20Examples%20Guide "Share on X") [  ](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-set-authorization-with-curl-full-examples-guide "Share on Facebook")    

 

 

Summarize this article with

 [  ](https://chat.openai.com/?q=Summarize%20this%20article%20and%20explain%20how%20Scrapfly%20helps%20me%20scrape%20any%20website%20at%20scale%20and%20bypass%20anti-bot%20systems%20for%20my%20use%20case%3A%20https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-set-authorization-with-curl-full-examples-guide) [  ](https://claude.ai/new?q=Summarize%20this%20article%20and%20explain%20how%20Scrapfly%20helps%20me%20scrape%20any%20website%20at%20scale%20and%20bypass%20anti-bot%20systems%20for%20my%20use%20case%3A%20https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-set-authorization-with-curl-full-examples-guide) [  ](https://x.com/i/grok?text=Summarize%20this%20article%20and%20explain%20how%20Scrapfly%20helps%20me%20scrape%20any%20website%20at%20scale%20and%20bypass%20anti-bot%20systems%20for%20my%20use%20case%3A%20https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-set-authorization-with-curl-full-examples-guide) [  ](https://www.perplexity.ai/search/new?q=Summarize%20this%20article%20and%20explain%20how%20Scrapfly%20helps%20me%20scrape%20any%20website%20at%20scale%20and%20bypass%20anti-bot%20systems%20for%20my%20use%20case%3A%20https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-set-authorization-with-curl-full-examples-guide) [  ](https://www.google.com/search?udm=50&aep=11&q=Summarize%20this%20article%20and%20explain%20how%20Scrapfly%20helps%20me%20scrape%20any%20website%20at%20scale%20and%20bypass%20anti-bot%20systems%20for%20my%20use%20case%3A%20https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-set-authorization-with-curl-full-examples-guide) 



cURl is a viable tool for requesting and transferring data from web pages. However, an obstacle is often encountered: authentication. In this guide, we'll explain how to set cURL authorization for different types:

- Basic authentication.
- Bearer token based authentication.
- Cookies authentication.

Let's get started!



## Basic Authentication With cURL

The basic auth credentials method is one of the oldest methods for managing HTTP authentication. It requires entering basic credentials data, username and password:



Basic auth example

Authentication in the above image can be found at `https://httpbin.dev/basic-auth/user/passwd` . It requires entering the auth credentials before the request can proceed to the data.

To set basic authentication with cURL, use `--user` or `-u` followed by the username and password. Basic is the default authentication method:

shell

```shell
curl --user user:passwd https://httpbin.dev/basic-auth/user/passwd
```



The above cURL command will enter the credentials data (`user` and `passwd`) to authorize the HTTP request. Here is the response of the above cURL command:

json

```json
{
  "authorized": true,
  "user": "user"
}
```





## Bearer Tokens With cURL

Bearer authentication sends a token in the `Authorization` header using the `Bearer` scheme. Basic authentication uses a different scheme: the previous Basic-auth endpoint does not issue a bearer token.

Use a bearer token issued by your API's authentication service. The `https://httpbin.dev/bearer` endpoint below accepts any non-empty token for demonstration; it does not validate a real API credential.



Authorization token on browser developer tools

Pass `Authorization: Bearer <token>` with the `-H` option:

shell

```shell
curl -sS --fail --max-time 30 -H 'Authorization: Bearer my-token-123' https://httpbin.dev/bearer
```



Response:

json

```json
{
  "authenticated": true,
  "token": "my-token-123"
}
```





Scrapfly

#### Scale your web scraping effortlessly

Scrapfly handles proxies, browsers, and anti-bot bypass — so you can focus on data.

[Try Free →](https://scrapfly.io/register)

## Authentication Cookies With cURL

Another popular authentication method is using [How to Handle Cookies in Web Scraping](https://scrapfly.io/blog/posts/how-to-handle-cookies-in-web-scraping), which function similarly to bearer tokens. After the credentials are validated successfully, a cookie value is created and saved to authorize future requests.

For this example, we'll use the login page on [web-scraping.dev](https://web-scraping.dev/login):



Login page on web-scraping.dev

The above page uses a login form for authentication. If we take a look at the cookies for this domain, we'll find a cookie value for authentication:



To handle cookie authentication with cURL, we'll pass this cookie value to the cURL command in either two ways:

- Adding it **as a cookie** value using the `-b` cURL option.
- Adding the cookie value **as a header** using the `-H` cURL option.

shell

```shell
curl -b "auth=user123-secret-token" https://web-scraping.dev/login
# or
curl -H "cookie: auth=user123-secret-token" https://web-scraping.dev/login
```



From the response, we can see that the cURL command was authenticated successfully:

html

```html
  <div class="container text-center">
    <div class="form-text mb-2">Logged in as User123</div>
    <div class="form-text mb-2">The secret message is:<div id="secret-message" class="fw-bold">🤫</div>
    </div>
    <a href="/api/logout"><button type="submit" class="btn btn-primary"> Logout </button> </a>
  </div>
```





For further details on cURL, including configuring its commands and using it for web scraping, refer to our dedicated guide.

[How to Use cURL For Web ScrapingIn this article, we'll go over a step-by-step guide on sending and configuring HTTP requests with cURL. We'll also explore advanced usages of cURL for web scraping, such as scraping dynamic pages and avoiding getting blocked.](https://scrapfly.io/blog/posts/how-to-use-curl-for-web-scraping)



 

   [  Add as a preferred source ](https://google.com/preferences/source?q=scrapfly.io) Table of Contents















 

  Table of Contents

- [Basic Authentication With cURL](#basic-authentication-with-curl)
- [Bearer Tokens With cURL](#bearer-tokens-with-curl)
- [Authentication Cookies With cURL](#authentication-cookies-with-curl)
 
    Join the Newsletter  Get monthly web scraping insights 

 

  



Scale Your Web Scraping

Anti-bot bypass, browser rendering, and rotating proxies, all in one API. Start with 1,000 free credits.

  No credit card required  1,000 free API credits  Anti-bot bypass included 

 [Start Free](https://scrapfly.io/register) [View Docs](https://scrapfly.io/docs/onboarding) 

 Not ready? [Get our newsletter](#newsletter-modal) instead. 

 

 

## Related Articles

 [     

 curl 

### How to Use cURL GET Requests

Here's everything you need to know about cURL GET requests and some common pitfalls you should avoid.

 

 ](https://scrapfly.io/blog/posts/how-to-use-curl-get-requests) [     

 http tools 

### How to Use cURL For Web Scraping

In this article, we'll go over a step-by-step guide on sending and configuring HTTP requests with cURL. We'll also explo...

 

 ](https://scrapfly.io/blog/posts/how-to-use-curl-for-web-scraping) [     

 http curl 

### How to Ignore cURL SSL Errors

Learn to handle SSL errors in cURL, including using self-signed certificates. Explore common issues, safe practices.

 

 ](https://scrapfly.io/blog/posts/guide-to-curl-ignore-ssl-errors) 

  

## Related Questions

- [ Q How to Set User Agent With cURL? ](https://scrapfly.io/blog/answers/how-to-set-curl-user-agent)
- [ Q How to click on cookie popups and modal alerts in Puppeteer? ](https://scrapfly.io/blog/answers/how-to-click-on-modal-alerts-like-cookie-pop-up-in-puppeteer)
- [ Q How to click on cookie popups and modal alerts in Playwright? ](https://scrapfly.io/blog/answers/how-to-click-on-modal-alerts-like-cookie-pop-up-in-playwright)
- [ Q How to click on cookie popups and modal alerts in Selenium? ](https://scrapfly.io/blog/answers/how-to-click-on-modal-alerts-like-cookie-pop-up-in-selenium)
 
  



   



 Scale your web scraping effortlessly, **1,000 free credits** [Start Free](https://scrapfly.io/register)