caprover / caprover-frontend

Frontend App for https://github.com/caprover/caprover
63 stars 91 forks source link

Using the frontend API programmatically with OTP enabled? #154

Closed ms4sman closed 2 months ago

ms4sman commented 2 months ago

Is it possible to programmatically use the frontend API when I have OTP enabled on my login?

I see that if I just provide a password like I used to, it will respond and tell me I need the OTP as well, which makes sense. But this is for a project that runs in the background as a job, so it needs to authenticate on its own without me intervening to give it an OTP.

Is there a way around this? Or is it simply not possible with OTP turned on?

Thanks!

githubsaturn commented 2 months ago

You can certainly obtain OTP as a parameter to the login screen:

curl 'https://captain.domain.com/api/v2/login' \
  -H 'accept: application/json, text/plain, */*' \
  -H 'content-type: application/json' \
  -H 'x-namespace: captain' \
  --data-raw '{"password":"MyPassword","otpToken":"123456"}'

Also there a lot of tools that can generate OTP tokens programmatically - here is one: https://otplib.yeojz.dev/