[Bash] Get value from the response

curl http://127.0.0.1:10080/login -u user

It prints out the token.

{"token":"eyJhbGciOwefewwefwIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InVzZXJAZXhhbXBsZS5jb20iLCJleHAiOjE2NTM2NzYzMjYsImlhdCI6MTY1MzQxNzEyNiwiaXNzIjoiYXV0aC5zZXJ2aWNlIiwic3ViIjoidXNlciJ9.G7C077LbtoL_FJF3s6wv1iMVGAiU-5zXWYpeJOnMDSY"}

You can copy and paste the long token in to the next command manually, but copying long, wrapped lines in cloud shell is broken. To work around this, you can either copy the JWT token in pieces, or - more easily - by assigning the token to a shell variable as follows

On shell 2 - login and assign the value of the JWT to a variable

TOKEN=$(curl http://127.0.0.1:10080/login -u user | jq -r '.token')

Check that it worked:

echo $TOKEN
posted @   Zhentiw  阅读(36)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
历史上的今天:
2020-05-25 [CSS] Siblings selector
2020-05-25 [Mise] Tips for Conducting a Code Review
2020-05-25 [Mise] Questions to Ask Yourself When Conducting a Code Review
2018-05-25 [Cypress] Create a Single Custom Cypress Command from Multiple Commands
2018-05-25 [Cypress] Wait for XHR Responses in a Cypress Test
2018-05-25 [Cypress] Load Data from Test Fixtures in Cypress
2018-05-25 [Cypress] Stub Network Requests in a Cypress Test
点击右上角即可分享
微信分享提示