-
Notifications
You must be signed in to change notification settings - Fork 93
Open
Description
Below it shows I login and get a token.
I try to list user and post a user. It says 401 unauthorized.
What am I doing wrong?
curl -i -H "Content-Type: application/json" -X POST \
-d '{ "name":"admin","password":"admin"}' \
http://192.168.88.60:3000/auth/login
albe@vamp398:~$ curl -i -H "Content-Type: application/json" -X POST \
> -d '{ "name":"admin","password":"admin"}' \
> http://192.168.88.60:3000/auth/login
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
X-DNS-Prefetch-Control: off
X-Frame-Options: SAMEORIGIN
Strict-Transport-Security: max-age=15552000; includeSubDomains
X-Download-Options: noopen
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Content-Type: text/html; charset=utf-8
Content-Length: 168
ETag: W/"a8-2z9KUtIl6PdNcjySGNF1khiX7OQ"
Date: Thu, 21 Jan 2021 03:37:06 GMT
Connection: keep-alive
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjEsInVzZXJuYW1lIjoiYWRtaW4iLCJpYXQiOjE2MTEyMDAyMjYsImV4cCI6MTYxMTIwMzgyNn0.4THpUDlL3uxmGk--rtS8j0KwQQQezREiogb3qnOFpvQ
albe@vamp398:~$
token='eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjEsInVzZXJuYW1lIjoiYWRtaW4iLCJpYXQiOjE2MTEyMDIzNzEsImV4cCI6MTYxMTUyOTk3MX0.ku36R217skI6u7sJkRfg4puWZ50ZS9OJnU7l4EjLyb0'
_____________
token='eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjEsInVzZXJuYW1lIjoiYWRtaW4iLCJpYXQiOjE2MTEyMDIzNzEsImV4cCI6MTYxMTUyOTk3MX0.ku36R217skI6u7sJkRfg4puWZ50ZS9OJnU7l4EjLyb0'
curl -i --request GET --url http://192.168.88.60:3000/user/1 \
--header 'content-type: application/json' --header "authorization: Bearer $token"
albe@vamp398:/srv/test/express-sqlite/jerrych25$ curl -i --request GET --url http://192.168.88.60:3000/user/1 \
> --header 'content-type: application/json' --header "authorization: Bearer $token"
HTTP/1.1 401 Unauthorized
Access-Control-Allow-Origin: *
X-DNS-Prefetch-Control: off
X-Frame-Options: SAMEORIGIN
Strict-Transport-Security: max-age=15552000; includeSubDomains
X-Download-Options: noopen
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Date: Thu, 21 Jan 2021 04:14:11 GMT
Connection: keep-alive
Content-Length: 0
_____________
albe@vamp398:~$ curl -i --request POST --url http://192.168.88.60:3000/user/ \
> --header 'content-type: application/json' --header "authorization: Bearer $token" \
> -d '{ "name":"dg","password":"dg"}'
HTTP/1.1 401 Unauthorized
Access-Control-Allow-Origin: *
X-DNS-Prefetch-Control: off
X-Frame-Options: SAMEORIGIN
Strict-Transport-Security: max-age=15552000; includeSubDomains
X-Download-Options: noopen
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Date: Fri, 22 Jan 2021 03:11:07 GMT
Connection: keep-alive
Content-Length: 0
Metadata
Metadata
Assignees
Labels
No labels