Cron job failed to get value from keyring

On a Linux box, I have the various passwords, etc. required for a backup stored in the keyring. I have scripted my backup operation and the script works as expected when invoked manually (with no prompts for passwords or other credentials). However, when I attempt to run it via cron, I get the following failure:

Failed to get the value from the keyring: keyring/dbus: Error connecting to dbus session, not registering SecretService provider: dbus: DBUS_SESSION_BUS_ADDRESS not set ssh_key_file is not found in Keychain/Keyring

What am I missing please?

Not sure if this is it, but maybe this helps?

I found a way to make this work.

First within the script, I added the following to get access to the correct DBUS_SESSION_BUS_ADDRESS

PID=$(pgrep -u <replace with target userid> bash | head -n 1)
DBUS="$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/"$PID"/environ | sed 's/DBUS_SESSION_BUS_ADDRESS=//' )"
export DBUS_SESSION_BUS_ADDRESS=$DBUS

Then, within the crontab entry, I force the target user by prepending the script with

sudo -u <target userid>