Service Account Usage
A service account allows authorization for internal headless scenarios (automated scripts, tests, etc...).
Generate a Service Account
- As the owner or manager of a Unity Organization, you can create a Service Account, and assign it any roles for this organization and its projects (depending on your needs).
- Once the account is created, be sure to store its credentials (
key IDandsecret key) in a secure and private location. - You can now refer to those credentials in your app, following the 'keyID:secret' format, to authorize your calls to Unity Cloud services.
Using the ServiceAccountAuthorizer
The ServiceAccountAuthorizer class implements the IServiceAuthorizer interface. Once instantiated, it can be injected in a ServiceHttpClient to
access Unity Cloud services.
m_ServiceAccountAuthorizer = new ServiceAccountAuthorizer(PlatformSupportFactory.GetAuthenticationPlatformSupport());
var httpClient = new UnityHttpClient();
var playerSettings = UnityCloudPlayerSettings.Instance;
m_ServiceHttpClient = new ServiceHttpClient(httpClient, m_ServiceAccountAuthorizer, playerSettings);
Inject the Service Account credentials in your Unity Cloud application
You can inject the Service Account credentials by either using command line arguments when launching the application or by defining an environment variable at the OS level.
Injecting credentials from a command line argument passed to the Unity Cloud application.
./MyApp.exe -UNITY_SERVICE_ACCOUNT_CREDENTIALS [keyID:secret]Injecting credentials from a
UNITY_SERVICE_ACCOUNT_CREDENTIALSenvironment variable set before running the Unity Cloud application.