SFTP Gateway 2.0 Getting Auth Token
Note: This page applies to SFTP Gateway version 2.x. Visit Here for documentation on version 3.x.
To use the api you need to obtain an authentication token.
To get it, here are two example curl commands:
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
Pass in the body of your request as a file
Your credentials 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:
Get users
curl -X GET \ https://<your sftpg ip>/backend/api/users \ -H 'Authorization: Bearer <token>' -k
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 ```
Delete a user
curl -X DELETE \ https://<your sftpg ip>/backend/api/users/<username> \ -H 'Authorization: Bearer <token>' -k