Trouble with Authentication in Unity Gaming Services: "PERMISSION_DENIED" Error

I’m currently working on integrating the Unity Gaming Services’ Dedicated Server and have run into an issue during the authentication process. I’m trying to sign up a server with a username and password, but I’m consistently receiving a WebRequestException with a PERMISSION_DENIED status. Here’s the error message:

WebRequestException: {"detail":"usernamepassword external id provider is not available: PERMISSION_DENIED","details":[],"status":401,"title":"PERMISSION_DENIED"}

This occurs after attempting to sign up using SignUpWithUsernamePasswordAsync method in my InitializeAndSignIn function. Here’s a snippet of my code for context:

private static async UniTask InitializeAndSignIn()
{
    Debug.Log(nameof(InitializeAndSignIn));

    var serverProfileName = $"User{Tool.GetRandomString(10)}";

    var initOptions = new InitializationOptions();
    initOptions.SetProfile(serverProfileName);
    await UnityServices.InitializeAsync(initOptions);

    try
    {
        await AuthenticationService.Instance.SignUpWithUsernamePasswordAsync($"{serverProfileName}", "Password1!");
    }
    catch (AuthenticationException e)
    {
        Debug.LogException(e);
    }
    catch (RequestFailedException e)
    {
        Debug.LogException(e);
    }
 
    Debug.Log(($"Signed in as {serverProfileName}"));
}

Additionally, I found this error in the server log files that might be related:

HttpException: (404) HTTP/1.1 404 Not Found
  at Unity.Services.Multiplay.Http.ResponseHandler.HandleAsyncResponse (Unity.Services.Multiplay.Http.HttpClientResponse response, System.Collections.Generic.Dictionary`2[TKey,TValue] statusCodeToTypeMap) [0x00082] in ./Library/PackageCache/com.unity.services.multiplay@1.1.1/Runtime/Http/ResponseHandler.cs:121
  at Unity.Services.Multiplay.Http.ResponseHandler.HandleAsyncResponse[T] (Unity.Services.Multiplay.Http.HttpClientResponse response, System.Collections.Generic.Dictionary`2[TKey,TValue] statusCodeToTypeMap) [0x00001] in ./Library/PackageCache/com.unity.services.multiplay@1.1.1/Runtime/Http/ResponseHandler.cs:227
  at Unity.Services.Multiplay.Apis.Payload.PayloadApiClient.PayloadAllocationAsync (Unity.Services.Multiplay.Payload.PayloadAllocationRequest request, Unity.Services.Multiplay.Configuration operationConfiguration) [0x00163] in ./Library/PackageCache/com.unity.services.multiplay@1.1.1/Runtime/Apis/PayloadApi.cs:111
  at Unity.Services.Multiplay.Internal.WrappedMultiplayService.GetPayloadAllocationAsPlainText () [0x0006e] in ./Library/PackageCache/com.unity.services.multiplay@1.1.1/Runtime/SDK/WrappedMultiplayService.cs:86
  at Unity.Services.Multiplay.Internal.WrappedMultiplayService.GetPayloadAllocationFromJsonAs[TPayload] (System.Boolean throwOnMissingMembers) [0x00020] in ./Library/PackageCache/com.unity.services.multiplay@1.1.1/Runtime/SDK/WrappedMultiplayService.cs:102
  at Server.OnMultiplayerAllocation (Unity.Services.Multiplay.MultiplayAllocation allocation) [0x00171] in /Users/wonsukyoon/Desktop/UnityProjects/Metaverse/Assets/DedicatedServerManager.cs:160
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state) [0x00000] in <e3aa8db986d7457ca73f10110f1283f5>:0
  at UnityEngine.UnitySynchronizationContext+WorkRequest.Invoke () [0x00002] in /home/bokken/build/output/unity/unity/Runtime/Export/Scripting/UnitySynchronizationContext.cs:153
  at UnityEngine.UnitySynchronizationContext.Exec () [0x0005d] in /home/bokken/build/output/unity/unity/Runtime/Export/Scripting/UnitySynchronizationContext.cs:83
  at UnityEngine.UnitySynchronizationContext.ExecuteTasks () [0x00014] in /home/bokken/build/output/unity/unity/Runtime/Export/Scripting/UnitySynchronizationContext.cs:107

(Filename: ./Library/PackageCache/com.unity.services.multiplay@1.1.1/Runtime/Http/ResponseHandler.cs Line: 121)

Could anyone help me understand why this permission issue is happening and how to resolve it? Any insights or suggestions would be greatly appreciated!

Permission denied => is your project linked? Does it have username/password authentication enabled?

You don’t need string interpolation here. But also confusing name, Authentication has profiles but here you are passing a “profile name” as a “user name”. Those are two different things!

1 Like

Issue resolved by “Project Settings” → “Services” → “Authentication” → “Identity Providers” → Add “Username and Password”.

1 Like