How to know when an RPC was called with key

Hello,

I have some admin RPC handlers in my Golang server plugin that are expected to be called from the Godot editor using rpc_async_with_key. My question is, how can I determined whether the RPC was in fact called using this method?
I noticed the context session/user variables are not set for these types of requests, but is there a better way to say “This RPC can only be called using a key”?

  1. Versions: Nakama 3.26 (Can upgrade. not an issue), Godot 4.6 using the offical Nakama Godot addon
  2. Server Framework Runtime language (If relevant): Golang

Hi @jonbonazza,

Checking the context for the userId is precisely how we recommend differentiating between an RPC caller being an user with an active session or via the runtime http key.

You can see the related docs and an example of how to guard these RPC from the client here: Server To Server - Heroic Labs Documentation.

Best.