You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何使用curl携带请求头参数发送GET请求?实操咨询

Correct curl GET Request with Authorization Token

Hey Ivan, glad you got your registration token sorted out! Here's how you can properly include it in your curl GET request to fetch user info:

The Working Command

curl -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjVhNzIwYzZkYzI2ZjNlNzRhMjZhODg1YiIsImlhdCI6MTUxNzQyMzcyNSwiZXhwIjoxNTE3NTEwMTI1fQ.W_lffqIlGh21UD2o4Sqd6mISrAC6PKv6swTQvQV1IfU" -X GET localhost:3002/api/auth/user

(Replace /api/auth/user with your actual user info endpoint if it differs from this example)

Key Details to Keep in Mind:

  • We use the -H flag to add the Authorization request header—this is the industry-standard way to send bearer tokens for API authentication.
  • Don’t forget the Bearer prefix (with a space after it!) before your token. Omitting this is one of the most common mistakes that leads to auth failures.
  • If your API expects the token in a custom header like X-Auth-Token instead, just swap out the header name, but Authorization: Bearer <token> is the most widely supported format.

Common Pitfalls to Avoid

If your earlier attempts failed, it was probably due to missing the Bearer prefix, using an incorrect header name, or formatting the header value improperly. The command above fixes these issues by following standard authentication practices.

内容的提问来源于stack exchange,提问作者Ivan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 03:14:09