C# Platform SDK setup
The SDK is compiled against .NET Framework 4.5.1 and .NET Standard 1.5, so it should work on any compatible .NET framework version. Both Mono 5 or .NET Core 2 are good choices that work on Linux, MacOS and Windows.
Downloading the C# Platform SDK
You can download the Platform SDK in C# using NuGet (unless you’re using a secure environment).
- Add the latest version of the NuGet package
Improbable.SpatialOS.Platformto your project via your IDE. For example, if you’re using Visual Studio, see these instructions.
- In a terminal window, run
nuget install Improbable.SpatialOS.Platform -OutputDirectory packages, which installs it into the directory “packages” relative to current directory.
For secure environments, the SpatialOS CLI package manager is the only option for downloading a bundle of the DLL and XML and its dependencies together.
To download to the file
spatial package get platform_sdk csharp <version> CSharpPlatfromSDK.zip
Once downloaded, unzip the file and reference all DLLs. The dependencies include the C# gRPC runtime, which you can’t reference directly, but you should still include it in your project and configure it to be copied to the output folder.
Authenticating your API calls
We require authentication to use the Platform SDK. It uses the same SpatialOS refresh token attached to a normal account or service account to authenticate your API calls. As a result, you must have either a SpatialOS user account or a service account to use the SDK.
The SDK is built to work together with the SpatialOS CLI’s built-in authentication mechanism. Alternatively, you can provide a refresh token string for the Platform SDK to use directly.
To use the SpatialOS CLI’s built-in authentication mechanism, run
spatial auth login. This obtains a copy of your refresh token and caches it locally. By default, the Platform SDK looks for the refresh token file stored locally (see the
spatial auth login documentation for details) and uses it to authenticate. Refresh tokens for normal user accounts expire relatively quickly; we’re currently working on a service account API which will let you set a longer expiry time.