Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

261
Views
How to make POST/GET curl request with token authentication?

I have APIKeyHeader description

Api is made with FastApi.

I've tried different ways like

curl -X GET -H "X-Access-Token: <token>" "https://example/v1/method/"

curl -X GET "https://example/v1/method/" --header '{"X-Access-Token": "token"}' 

And the answer is the same: {"detail": "Could not validate credentials"} but I know that token is correct.

P.S. new to curl, please could you describe my mistake in detail

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can use

curl -X GET "https://example/v1/method/" -H "Authorization: Bearer TOKEN_HERE"

Let's assume that I have an endpoint /users/me, if I send an HTTP request to that endpoint with the cURL command above.

curl -X GET "http://127.0.0.1:8000/users/me" -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiMDY1ODQwNDEtYzYwYi00NDg4LWEyYzctZmRkZmQxNWI0NDNkIiwiYXVkIjoiZmFzdGFwaS11c2VyczphdXRoIiwiZXhwIjoxNTk1NzA3ODYyfQ.yutytBX0hmv0MJy5BMSfGSBqrPvFzKqLq_-quEgNyF4"

It works perfectly.

Out:  {"id":"06584041-c60b-4488-a2c7-fddfd15b443d","email":"user@gmail.com","is_active":true,"is_superuser":false}
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!