Call from Unity game server (Multiplay Hosting)
Invoke scripts from a dedicated game server using Multiplay Hosting.
Read time 1 minuteLast updated a day ago
You can call a script from a dedicated game server using Multiplay Hosting.
Prerequisites
- The game server you are invoking Cloud Code from and any related resources must exist in the same Unity Dashboard project and environment.
- Onboard with Multiplay Hosting.
Call out to Cloud Code
Follow the steps below to call out to a Cloud Code script from a game server.Authentication
You can authenticate requests using a Multiplay Hosting token_token) or a stateless token. Use the received token as a bearer token for HTTP authentication in the request header.Authenticate using a Multiplay Hosting token
See the Game Server Documentation here.Authenticate using a stateless token
To use a stateless token, you need to create a service account and call the Token Exchange API. Refer to authenticating trusted clients for the Cloud Code Client API).Call a script
You can call the script using any HTTP library that is native to the codebase. Use the retrieved authentication token as a bearer token for HTTP authentication in the request header. An example CURL request to call a script using the Cloud Code API could look like this:curl -X POST -H "Authorization: Bearer <BEARER_TOKEN>" 'https://cloud-code.services.api.unity.com/v1/projects/<PROJECT_ID>/scripts/<SCRIPT_NAME>'