Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

257
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda