Wiki
Clone wikisftpgateway-public / 2.0 Getting Auth Token
SFTP Gateway Api
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 file will look like this (creds.txt):
And the curl command will look like this:{"username":"admin","password":"<your password>"}
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
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
curl -X DELETE \ https://<your sftpg ip>/backend/api/users/<username> \ -H 'Authorization: Bearer <token>' -k
Updated