Hi,
I want to get access of the username of a player in the server side, which is stored in the cloud save: player data but to get access I need to log in with an admin account, I tested the ServiceAccount but there is no documentation about how to connect to the service account.
I tested this method:
ServerAuthenticationService.Instance.SignInWithServiceAccountAsync();
but I have this error:
ServerAuthenticationException: HTTP/1.1 400 Bad Request
3 Answers
3
Did you fix the issue? I’ve tried almost everything!
Hi all,
i’m trying to authenticate a self-hosted dedicated server (not Multiplay) against UGS Authentication using a service-account key,
but every call to ServerAuthenticationService.Instance.SignInWithServiceAccountAsync(keyId, secret) returns: ServerAuthenticationException: HTTP/1.1 400 Bad Request.
The Simple Authentication Code:
private const string keyId = "9fb5-7c97927f1ef7-f80b-44e1-f4acaa79"; // not my real key
private const string secretKey = "XlCwE48G0iZ-Q0WCwzLnYFQ_5NtxS0-T"; // …
Hello
Please make sure your service account has the Unity Environments Viewer role.
The operations needs to access the environments to get the environment id based on the environment name provided.
Unfortunately we do not provide enough information at this time in the error.
This is something we are looking to improve soon.
For me, it wasn’t because the service account didn’t have the Unity Environments Viewer role.
If that was the case for you, check this:
Found the fix!
TL;DR:
The issue was caused by using the ENABLE_UCS_SERVER scripting define symbol instead of UNITY_SERVER. Switching to UNITY_SERVER fixed the 400 Bad Request error when calling SignInWithServiceAccountAsync.
Background
The Unity.Services.Authentication.Server namespace (which contains ServerAuthenticationService) is conditionally compiled based on an assembly definition file (.asmdef):
Navigate to Packages/Authentication/Server in your Project window.
Open Unity.Services.A…
Also, you can check this guide i wrote:
Unity’s documentation doesn’t cover server authentication with service accounts, so I’m sharing this guide to fill that gap.
1. Connect Your Project to the Unity Cloud
Ensure your Unity project is linked to your UGS project.
Learn how here: Unity UGS Authentication Get Started
2. Create a Service Account Key in the Dashboard
Open your Unity Cloud Dashboard .
Select your Organization and Project.
Navigate to Project Settings (in the sidebar) > Service Accounts.
Click + New Service Account, g…
Hello! I don't have an answer but I can add my two cents as I am in the same boat as you. I found this documentation: https://docs.unity3d.com/Packages/com.unity.services.authentication@3.1/api/Unity.Services.Authentication.Server.IServerAuthenticationService.SignInWithServiceAccountAsync.html#Unity_Services_Authentication_Server_IServerAuthenticationService_SignInWithServiceAccountAsync_System_String_System_String_ In my case I supplied both parameters that are required and I am stuck on error 404 Forbidden. I've given the service account about every permission I can find and nothing.
– MasterAran