#Can I use Unity Player Accounts for C# .NET for a full stack web application as the Auth?

1 messages · Page 1 of 1 (latest)

flat echo
#

I might use Unity Player Accounts for auth in UGS, but I need to know first if I can use it to auth players in through a full stack web application.

I know Unity Player accounts only supports C#. bit can it support C# .NET with Blazor in a full stack web application?

mental hull
#

I’m not really sure what you’re asking. UPA is designed to provide a sign in solution for applications built with Unity. Anything outside of that would be an unintended use.

long skiff
#

I don't think Unity Authentication returns Oauth tokens

flat echo
#

my bad.

I thought UPA uses a C# sdk provided by Unity. So I thought I could use that sdk for a .NET web application.

But it seems like UPA can really only be used for Unity.

And just to be sure, If I do a headless build of Unity, and use the headless build as a backend, UPA still wouldn't be a good solution since it is only for front end Unity apps?

long skiff
#

Your unity server can authenticate with a UGS service token. Only users would be using the Player Accounts. There is a rest API that you can use as well. Technically I guess it could be used on the web.

flat echo
#

ok thanks. UPA will not integrate well in a .NET web app.

Will look into other solutions.

flat echo
# long skiff Your unity server can authenticate with a UGS service token. Only users would be...

Can you check if it makes sense? I basically need a way to do auth for both web application and the unity application. and I think custom ID is the answer.

Tauri application acts as a game launcher. Players sign into the game launcher using their own auth. (could be clerk, AWS cognito, firebase or our own auth).

When the player wants to launch the game through the launcher, they do an API call to our backend to test that the player is still logged in. If they are not logged in to the game launcher, then they are logged out of the game launcher are are prompted to log back in. If they are logged in while trying to open the game, then the game opens.

When the player on Tauri does an API call to test if the player is still logged in to open the game, the API endpoint in our custom backend attempts to do a Sign in With Custom ID. clerk_user_id / firebase_user_id or our_own_auth_user_id.

Our backend sends this to UGS as a Sign In With Custom ID, through Token Exchange API first and then exchanges our user id for a Unity Player Id with this endpoint https://player-auth.services.api.unity.com/v1/projects/<PROJECT_ID>/authentication/server/custom-id
. We then get the resulting JSON object, such as userId, idToken, and sessionToken, and pass it to the Tauri Game Launcher.

Tauri Game launcher then launches the Unity Game and passes in the idToken as the AccessToken, and the sessionToken as the sessionToken for AuthenticationService.Instance.ProcessAuthenticationTokens(userTokens.AccessToken, userTokens.SessionToken);

If an exception occurs and the custom id sign in fails in the unity app, exit out.

If signin succeeds in Unity, then player can now use all of the UGS services and play as normal.