update domain names with the cli (yet another topic)
-
@fbartels thank you; is there any other way, opposed to reverse engineer front-end from the back-end, or at least to make it more understandable and repeat-able, for those, who is not a front-end developer, like myself?
For example, how do I find this particular request, on top of dozens (at least) others? Would it be supported in the future or it's something that can be broken easily? Where do I get token? Can it expire?
If things can expire, is there any better way to handle things?I understand it's not very typical request, I appreciate your help, just trying to make sense of it.
@potemkin_ai while there is no cli subcommand as such, as @fbartels correctly mentioned, there is a REST api, which the Cloudron dashboard also uses.
I have documented it now at https://docs.cloudron.io/api.html#tag/Cloudron/paths/~1cloudron~1renew_certs/post -
@potemkin_ai while there is no cli subcommand as such, as @fbartels correctly mentioned, there is a REST api, which the Cloudron dashboard also uses.
I have documented it now at https://docs.cloudron.io/api.html#tag/Cloudron/paths/~1cloudron~1renew_certs/post@nebulon oh, that's wonderful!
May I ask you for some help in here, please?
I did the call 'curl -k -X POST -H 'Content-Type: application/json' --data '{"domain": "sub.domain.name"}' https://mydomain.name//api/v1/cloudron/renew_certs
and it failed with the following error:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Error</title> </head> <body> <pre>Cannot POST //api/v1/cloudron/renew_certs</pre> </body> </html>What am I missing here?
-
@nebulon oh, that's wonderful!
May I ask you for some help in here, please?
I did the call 'curl -k -X POST -H 'Content-Type: application/json' --data '{"domain": "sub.domain.name"}' https://mydomain.name//api/v1/cloudron/renew_certs
and it failed with the following error:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Error</title> </head> <body> <pre>Cannot POST //api/v1/cloudron/renew_certs</pre> </body> </html>What am I missing here?
@potemkin_ai were you using the dashboard domain. As in my.example.com ?
-
@potemkin_ai were you using the dashboard domain. As in my.example.com ?
@nebulon nop; but I changed it to be my.sub-domain.domain.name, which is exactly a cloudron address, and get the very same error there.
As I wrote I realized that I used double slash after the domain name - that broke out things, which I didn't expected...
Got the new error - could you please, assist me - how to get the token?
{ "status": "Unauthorized", "message": "Token required" } -
@nebulon nop; but I changed it to be my.sub-domain.domain.name, which is exactly a cloudron address, and get the very same error there.
As I wrote I realized that I used double slash after the domain name - that broke out things, which I didn't expected...
Got the new error - could you please, assist me - how to get the token?
{ "status": "Unauthorized", "message": "Token required" }@potemkin_ai you need to provide an access token for verification as mentioned on the top of https://docs.cloudron.io/api.html
Such api tokens can be created in the profile page in your Cloudron dashboard.
-
@potemkin_ai you need to provide an access token for verification as mentioned on the top of https://docs.cloudron.io/api.html
Such api tokens can be created in the profile page in your Cloudron dashboard.
@nebulon Thank you.
For the future guys like me - that's in profile page.I've added the token, but it still generate an error:
curl -k -X POST -H 'Content-Type: application/json' -H 'Bearer: $TOKEN' --data '{"domain": "my.sub.domain.com"}' https://my.sub.domain.com/api/v1/cloudron/renew_certsGenerates the same error:
{ "status": "Unauthorized", "message": "Token required"Request via ?access_token=<token> works, though.
Is there something I'm missing with passing token as a header? Tried both "Bearer: $token" and "Bearer $token" - same result.
-
@nebulon Thank you.
For the future guys like me - that's in profile page.I've added the token, but it still generate an error:
curl -k -X POST -H 'Content-Type: application/json' -H 'Bearer: $TOKEN' --data '{"domain": "my.sub.domain.com"}' https://my.sub.domain.com/api/v1/cloudron/renew_certsGenerates the same error:
{ "status": "Unauthorized", "message": "Token required"Request via ?access_token=<token> works, though.
Is there something I'm missing with passing token as a header? Tried both "Bearer: $token" and "Bearer $token" - same result.
@potemkin_ai said in update domain names with the cli (yet another topic):
Is there something I'm missing with passing token as a header?
It needs to be
-H "authorization: Bearer $TOKEN". -
@potemkin_ai said in update domain names with the cli (yet another topic):
Is there something I'm missing with passing token as a header?
It needs to be
-H "authorization: Bearer $TOKEN".For the future me, here is a two minutes guide I wish I had when I started:
- Go to the profile page on your Cloudron, generate the token there.
- Create the script you want to be executed and here is the part of it, in charge of the API calls:
dns_host_name='my.your_instance.name' token='token_you_just_generated' set +e set +x #do your voodoo here; in my case - it's firewall rules altering curl -k -X POST -H 'Content-Type: application/json' -H "authorization: Bearer $token" --data '{"domain": "'$dns_host_name'"}' https://$dns_host_name/api/v1/cloudron/renew_certs echo "You can check the status of the task at https://$dns_host_name/logs.html?taskId=$task_id_from_above" sleep 180 #do your next voodoo here - in my case, altering firewall rules back -
@nebulon indeed, thank you!
For the sake of future users, I guess it could make sense to add information about where to take token and full command line for cURL into the documentation, but it's not directly related to the case.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login