2.0 Getting Auth Token | Thorn Technologies

2.0 Getting Auth Token

To use the api you need to obtain an authentication token.

To get it, here are two example curl commands:

  1. Pass in the body of your request as a string

    curl -iX POST \
    https://<your sftpg ip>/backend/login \
    -H 'Content-Type: application/json' \
    -d '{ "username": "admin", "password": "<your password>" }' -k
    
  2. Pass in the body of your request as a file Your file will look like this (creds.txt):

    {"username":"admin","password":"<your password>"}
    

    And the curl command will look like this:

    curl -iX POST \
    https://<your sftpgw ip>/backend/login \
    -H 'Content-Type: application/json' \
    --data '@/path/to/file/creds.txt' -k
    

The response will return authorization header with the token you need to make all the subsequent requests.

Authorization: Bearer <token>

Copy the token. To make requests with this token here are some examples:

1. Get users

curl -X GET \
    https://<your sftpg ip>/backend/api/users \
    -H 'Authorization: Bearer <token>' -k

2. Create a user

curl -X POST \
  https://<your sftpg ip>/backend/api/users \
  -H 'Authorization: Bearer <token>' \
  -H 'Content-Type: application/json' \
  -d '{ "username": "chris", "bucketName": "", "path": "", "pubSsh": "", "s3EncryptionLevel": "" }' -k

3. Delete a user

curl -X DELETE \
    https://<your sftpg ip>/backend/api/users/<username> \
    -H 'Authorization: Bearer <token>' -k