I have to communicate with more than two devices which have been working perfectly with Google NearbyAPI Connections. Now I need to secure the connection restricting the access to the cluster network. The API exposes a method to authenticate the devices, which is used with a token provided by the library, however, this token is intended to be authorized by two users in the UI. I need to do this programmatically, the user shouldn't do this.
There's a method to obtain a token to authenticate programatically, can be found in the docs, but it's not available in the library.
What I have tried to do:
As I don't see a way declared by the docs to do it without asking the user to accept the connection I had tried:
Putting a secret in the end of the endpoint
id-secret
So each device should decrypt the secret and validate the info matches the one registered and then accept the connection. But encrypting using AES consumes produce a long payload and this provokes that the devices are not discovered. I haven't tried with TDES as it supposes to provide a smaller payload, but I'm not sure if this will be the way to go.Accepting the connection send the secret and if not valid disconnect. I don't see this a good option as the network will be expose to anyone and it can produce unstable behaviours.
What do you think might be a good approach to authenticate the devices? As the only entry point of information I see is the Endpoint.