# .NET Server integration

**URL:** <https://forum.heroiclabs.com/t/net-server-integration/4021>\
**Category:** Client Libraries\
**Created:** [July 6, 2023, 8:06pm UTC](https://forum.heroiclabs.com/t/net-server-integration/4021 "2023-07-06T20:06:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![matiasvillanueva](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/matiasvillanueva/32/1287_2.png) [@matiasvillanueva](https://forum.heroiclabs.com/u/matiasvillanueva)\
**Post date:** [July 6, 2023, 8:06pm UTC](https://forum.heroiclabs.com/t/net-server-integration/4021/1 "2023-07-06T20:06:13Z")

</div>

Hi! I’m new to Nakama so forgive me if this has been addressed somewhere else.

I have a Unity game with a .NET Core REST backend that will connect to Nakama. Ex:

Client =\> Backend (with nakama SDK) =\> Nakama

I am not finding a way to send the session to the client and then for the client to send it back to the Backend for calling rpcs.

I thought that serializing the session to send it as a string to the client and then deserializing it back will work, but Nakama.Session does not have a constructor.

```auto
var session = Task.Run(async () =>
        {
            var session = await Client.AuthenticateDeviceAsync(deviceId);
            return session;
        }).Result;
        
        return JsonConvert.SerializeObject(session);

```

And when I get a call from Unity:

```auto
var nakamaSession = JsonConvert.DeserializeObject<Nakama.Session>(session);
        
        var objects = Task.Run(async () =>
        {
            return await Client.ReadStorageObjectsAsync(nakamaSession,
                new[] { new StorageObjectId() { Collection = collection, Key = key, UserId = nakamaSession.UserId } });
        }).Result;

```

Nakama.Session does not have a constructor, so that fails.

Is there a way to achieve this? Is there a better patter for this kind of case?

Thanks.-

---

<div class="post-metadata">

**Author:** ![igordias2](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/igordias2/32/1596_2.png) [@igordias2](https://forum.heroiclabs.com/u/igordias2)\
**Post date:** [July 7, 2023, 12:02am UTC](https://forum.heroiclabs.com/t/net-server-integration/4021/2 "2023-07-07T00:02:54Z")

</div>

Hi Matias!

Ive already tried in the beggining to do the same way as you, but after some research Ive found that is possible but will be a lot of headache to maintain and secure a connection like this.

> [@matiasvillanueva](#):
>
> Client =\> Backend (with nakama SDK) =\> Nakama

The “nakama SDK” that you is referring is a Client SDK.  
So it`s like: A Lot of Clients (Unity clients) =\> Client (.NET Core) =\> Nakama

If you want to a different backend to do other backend stuff will be easier to go on this configuration

Clients =\> Nakama =\> Backend (.Net Core)  
with nk.httpRequest on the Nakama Server to access the .NET Core

Im working with this to access some wrappers and apis that is hard to achieve on the TS Server-Framework

---

<div class="post-metadata">

**Author:** ![matiasvillanueva](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/matiasvillanueva/32/1287_2.png) [@matiasvillanueva](https://forum.heroiclabs.com/u/matiasvillanueva)\
**Post date:** [July 17, 2023, 10:20pm UTC](https://forum.heroiclabs.com/t/net-server-integration/4021/3 "2023-07-17T22:20:50Z")

</div>

@novabyte I saw in this post: [ASP .NET Core Server Integration](https://forum.heroiclabs.com/t/asp-net-core-server-integration/400)

You encourage this architecture. How do you suggest handling the session?

---

<div class="post-metadata">

**Author:** ![novabyte](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/novabyte/32/1324_2.png) [@novabyte](https://forum.heroiclabs.com/u/novabyte)\
**Post date:** [July 21, 2023, 1:26pm UTC](https://forum.heroiclabs.com/t/net-server-integration/4021/4 "2023-07-21T13:26:19Z")

</div>

@matiasvillanueva I haven’t looked at the other thread. It’s been quite a while since I helped with the other thread. You can use `Session.Restore(..., ...)` in the .NET client to restore a `AuthToken` and `RefreshToken` (JWTs) into an `ISession` type.
