httpie shell session

#507
Raw
Author
winny
Created
June 18, 2022, 11:41 p.m.
Expires
Never
Size
3.0 KB
Hits
160
Syntax
None
Private
✗ No
winston@voyager ~ $ http POST https://sillypaste.herokuapp.com/api/login/ username=winny password="$pwd"
HTTP/1.1 200 OK
Allow: POST, OPTIONS
Connection: keep-alive
Content-Length: 52
Content-Type: application/json
Date: Sat, 18 Jun 2022 23:39:24 GMT
Referrer-Policy: same-origin
Server: gunicorn
Vary: Cookie
Via: 1.1 vegur
X-Content-Type-Options: nosniff
X-Frame-Options: DENY

{
    "token": "1a63b6445e2df1cbdfa22a3a39cdb4cdb899d22e"
}


winston@voyager ~ $ token=1a63b6445e2df1cbdfa22a3a39cdb4cdb899d22e
winston@voyager ~ $ http GET https://sillypaste.herokuapp.com/api/user/me/ "Authorization: Token $token"
HTTP/1.1 200 OK
Allow: GET, PUT, HEAD, OPTIONS
Connection: keep-alive
Content-Length: 43
Content-Type: application/json
Date: Sat, 18 Jun 2022 23:39:55 GMT
Referrer-Policy: same-origin
Server: gunicorn
Vary: Accept
Via: 1.1 vegur
X-Content-Type-Options: nosniff
X-Frame-Options: DENY

{
    "id": 2,
    "is_staff": true,
    "username": "winny"
}


winston@voyager ~ $ http POST https://sillypaste.herokuapp.com/api/paste/ "Authorization: Token $token"
HTTP/1.1 400 Bad Request
Allow: GET, POST, HEAD, OPTIONS
Connection: keep-alive
Content-Length: 72
Content-Type: application/json
Date: Sat, 18 Jun 2022 23:40:05 GMT
Referrer-Policy: same-origin
Server: gunicorn
Vary: Accept
Via: 1.1 vegur
X-Content-Type-Options: nosniff
X-Frame-Options: DENY

{
    "body": [
        "This field is required."
    ],
    "title": [
        "This field is required."
    ]
}


winston@voyager ~ $ http POST https://sillypaste.herokuapp.com/api/paste/ "Authorization: Token $token" body='hello from httpie https://httpie.io/' title='http hello world'
HTTP/1.1 201 Created
Allow: GET, POST, HEAD, OPTIONS
Connection: keep-alive
Content-Length: 208
Content-Type: application/json
Date: Sat, 18 Jun 2022 23:40:33 GMT
Referrer-Policy: same-origin
Server: gunicorn
Vary: Accept
Via: 1.1 vegur
X-Content-Type-Options: nosniff
X-Frame-Options: DENY

{
    "author": null,
    "body": "hello from httpie https://httpie.io/",
    "expiry": null,
    "freeze_hits": false,
    "hits": 0,
    "id": 506,
    "language": null,
    "size": 52,
    "timestamp": "2022-06-18T23:40:33.756780Z",
    "title": "http hello world"
}


winston@voyager ~ $ http POST https://sillypaste.herokuapp.com/api/logout/ "Authorization: Token $token" 
HTTP/1.1 200 OK
Allow: POST, OPTIONS
Connection: keep-alive
Content-Length: 19
Content-Type: application/json
Date: Sat, 18 Jun 2022 23:40:50 GMT
Referrer-Policy: same-origin
Server: gunicorn
Vary: Accept
Via: 1.1 vegur
X-Content-Type-Options: nosniff
X-Frame-Options: DENY

{
    "logged_out": true
}


winston@voyager ~ $ http GET https://sillypaste.herokuapp.com/api/user/me/ "Authorization: Token $token"
HTTP/1.1 401 Unauthorized
Allow: GET, PUT, HEAD, OPTIONS
Connection: keep-alive
Content-Length: 27
Content-Type: application/json
Date: Sat, 18 Jun 2022 23:40:57 GMT
Referrer-Policy: same-origin
Server: gunicorn
Vary: Accept
Via: 1.1 vegur
Www-Authenticate: Token
X-Content-Type-Options: nosniff
X-Frame-Options: DENY

{
    "detail": "Invalid token."
}