As far as GNOME is concerned, there is no “desktop”, just the background. I assume that’s not what you want to focus?
If you use some extension that puts objects on the desktop, then it’s probably better to modify the extension itself than developing a separate extension that interacts with it (for starters, you’d have to handle the cases where a different desktop icons extension is used, or no extension at all).
If the objects are provided by an app window (like the old nautilus-desktop, or the desktop-icons-ng extension), then you can focus the window, but you won’t be able to influence the keyboard focus inside the window.
The reason I am looking for a desktop object is that I want to be able to set the focus on it (like with the .activate methods).
Let’s say I have two monitors, and one of them has a workspace with no windows on it. I would like to set focus on that desktop so that I can use the keyboard arrows to switch between desktop icons. How would I do that?
As I said, there’s nothing on desktops as far as GNOME is concerned. That is, any answer depends on the specific extension/app you are using to put icons there.