API Create Users #815
-
Hello! I am working on setting up SFTPGO for my company in a testing environment as a Proof of Concept project before we use it in production. I am deploying to GKE with the provided Docker image (2.2.3-alpine). I am using a MySQL Backend and storing files in GCS. Everything is working fine via the Web Client. However, the next step for my Proof of Concept is being able to dynamically create Users via the API. I looked at the Swagger UI and was able to create a new user--it shows up in the UI and in the database it looks nearly identical to the other user (with the exception of the username). My problem, is that the user I created via the UI allows me to login to the Web Client via username/password. But the user I created via the API (same password) shows me a decryption error. I tried to go into the Admin Client and force a password change in the UI, thinking that would work--but I still get the same error on that user. The password I provided in the original HTTP Post request was sent plain text like:
And when I inspect the Am I doing something wrong? I feel like I'm missing something easy here 😄 EDIT: I was able to get the API to work to allow me to login when creating my user by changing this line during my POST request: "gcsconfig": {
"bucket": "my-bucket",
"key_prefix": "my-prefix/",
"automatic_credentials": 1
}, Now my login works--Why wasn't the login working when I passed the payload JSON data from my GCS Credentials file before? Also--I have a new error. When I login to this new user created via the API, it fails to load my files at the FILES page after login. When I go to GCS, I notice that my new user doesn't have a folder created (the prefix name provided in the snippet above didn't create a GCS folder). Is this expected behaviour? Thanks! FINAL EDIT: So the last thing I tried--was going into the Admin Client as my Admin User and updating the user I created via the API. I turned OFF automatic credentials. Then I explicitly re-uploaded the SAME JSON credentials file. Now everything works. So now I just need to figure out how to correctly do this via the API. Looking at the Swagger API Docs again, I think I am missing something, but I'm not entirely sure what I'm supposed to do here: I noticed after I uploaded the SAME json file that when I inspect the database that the values in gcsConfig are different between the two users. So when I make this call via the API, how to I determine what goes in these fields? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi, you almost answered your question by yourself. To set GCS credentials you have to set the Side note: please set |
Beta Was this translation helpful? Give feedback.
Hi,
you almost answered your question by yourself. To set GCS credentials you have to set the
status
toPlain
and thepayload
to the content of your credential file (as string). SFTPGo will encrypt the credentials before saving the user and will set the status toSecretbox
by default.Side note: please set
prefer_database_credentials
totrue
to simplify future upgrade to v2.3.x