Having trouble authenticating in my APP to the hub with security settings on

Has anyone have a method (preferable in java) to authenticate with the hub IP. I tried doing a post passing username and password to the body but I don't get a cookie back. Is there a method documented that I am missing somewhere? Of course the URLS are easily accessible for the hub if security/password protects of hub is off.

I tried using this method translated to java

I am trying to authenticate outside the hub. I get a parsing error when I try to submit login as he did in groovy like it won't accept the post. Oddly enough its throwing a 500 error when i try to post to hubip/login

Perhaps this curl script will be useful to you; unless you are trying to create a Groovy app that runs on the hub itself.

1 Like

Couple quick edits to that backup script -- use this to get the find command to work: find "$backupdir" -name "*.lzf" -mtime +10 -exec rm {} \;

(If you're nervous about that rm command, first change the rm to ls -l and run it to see what files it finds.)

And my backupdir has a space in the name, so I needed a bunch of " around things. Here's the updated version:

#!/bin/bash
# Script to download hubitat backup
he_login="XXX" #This is the username you use to log into the hub
he_passwd="XXX" #This is the password you use to log into the hub
he_ipaddr="XXX" #This is the host name or IP of the hub
backupdir='/volume1/Dir With Spaces/HubitatBackups'
cookiefilename="/cookiefile.txt"
cookiefile=$backupdir$cookiefilename
backupfile=$backupdir/LVRM_$(date +%Y%m%d-%H%M).lzf

#Delete Files more than 10 days old
find "$backupdir" -name "*.lzf" -mtime +10 -exec rm {} \;

# Fetch login page with user/pass to get a session cookie
curl -k -c "$cookiefile" -d username=$he_login -d password="$he_passwd" https://$he_ipaddr/login

# Now get the actual backupfile sending the session cookie
curl -k -sb "$cookiefile" https://$he_ipaddr/hub/backupDB?fileName=latest -o "$backupfile"

# remove the session cookie file
rm "$cookiefile"