# Godot session vars doesn't work during authentication

**URL:** <https://forum.heroiclabs.com/t/godot-session-vars-doesnt-work-during-authentication/2492>\
**Category:** Client Libraries\
**Tags:** sdk-godot\
**Created:** [April 3, 2022, 11:43pm UTC](https://forum.heroiclabs.com/t/godot-session-vars-doesnt-work-during-authentication/2492 "2022-04-03T23:43:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rretureau](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/rretureau/32/1055_2.png) [@rretureau](https://forum.heroiclabs.com/u/rretureau)\
**Post date:** [April 3, 2022, 11:43pm UTC](https://forum.heroiclabs.com/t/godot-session-vars-doesnt-work-during-authentication/2492/1 "2022-04-03T23:43:11Z")

</div>

Hey everyone,

It seems that session vars can’t be sent through authentication. I dived in and found a fix that imply modifying Nakama godot module. Here are some notable points :

**1. Documentation about session vars in Godot is invalid**

```auto
var vars = {
    "device_os" = OS.get_name,
    "device_model" = OS.get_model_name,
    "invite_user_id" = "<some_user_id>,
    # ...
}

var session : NakamaSession = yield(client.authenticate_device_async("<device_id>", null, true, vars), "completed")

```

This is not how we declare a dictionnary in Godot. I did the following

```auto
var vars = {
    "somekey" : "somevalue",
}

var session : NakamaSession = yield(client.authenticate_device_async("<device_id>", null, true, vars), "completed")

```

**2. Nakama serializer does not handles dictionnary in NakamaSerializer.gd**

```auto
		TYPE_DICTIONARY: # Maps
			var dict = {}
			if content == TYPE_OBJECT: # Map of objects
				for l in val:
					if val_type != TYPE_OBJECT:
						continue
					dict[l] = serialize(val)
			else: # Map of simple types
				for l in val:
					dict[l] = val[l]
					if val_type != content:
						continue
					dict[l] = val

```

It seems that the dict defined here is never added to the “out” variable that is returned. Which basically mean that the dict var is declared but never used. It also seems that “val\_type” is never equal to “content”.

To be 100% honest, i’m not totally sure to understand how the whole serializer works, but what I know is that it remove the “vars” defined in the authenticate function and nothing is sent.

I did a quick and dirty fix, but this might not be the real solution to that :

```auto
			TYPE_DICTIONARY: # Maps
				var dict = {}
				if content == TYPE_OBJECT: # Map of objects
					for l in val:
						if val_type != TYPE_OBJECT:
							continue
						dict[l] = serialize(val)
				else: # Map of simple types
					for l in val:
						dict[l] = val[l]
					out[k] = dict

```

But maybe my problem comes from the vars definition. Is it supposed to be a dictionnary ?

Thanks in advance for your help ;).

---

<div class="post-metadata">

**Author:** ![ftkg](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/ftkg/32/1180_2.png) [@ftkg](https://forum.heroiclabs.com/u/ftkg)\
**Post date:** [April 4, 2022, 2:07pm UTC](https://forum.heroiclabs.com/t/godot-session-vars-doesnt-work-during-authentication/2492/2 "2022-04-04T14:07:17Z")

</div>

Hello @rretureau,

Yes, the vars are supposed to be a dictionary. The documentation is in my view correct and is just showing you a sample of what type of data you could pass as session vars.

A fix to dictionary de-serialization has been merged recently ([Correctly (de-)serialize floats in dictionaries to fix "numeric\_prope… · heroiclabs/nakama-godot@cdbcf2c · GitHub](https://github.com/heroiclabs/nakama-godot/commit/cdbcf2c3f1d7e2bd3d2518c573fee38a74ba6503)) and may be related your issue, can you update to the latest version and check if it is resolved?

---

<div class="post-metadata">

**Author:** ![rretureau](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/rretureau/32/1055_2.png) [@rretureau](https://forum.heroiclabs.com/u/rretureau)\
**Post date:** [April 9, 2022, 2:33am UTC](https://forum.heroiclabs.com/t/godot-session-vars-doesnt-work-during-authentication/2492/3 "2022-04-09T02:33:49Z")

</div>

Thanks for your answer.

For the dictionnary, there is a structural error in the exemple ( “=” symbol instead of “:” in the dictionnary definition). That’s what I am referring to.

For the version, i’m already using the latest version and the fix does not seems to work.

---

<div class="post-metadata">

**Author:** ![ftkg](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/ftkg/32/1180_2.png) [@ftkg](https://forum.heroiclabs.com/u/ftkg)\
**Post date:** [April 11, 2022, 2:44pm UTC](https://forum.heroiclabs.com/t/godot-session-vars-doesnt-work-during-authentication/2492/4 "2022-04-11T14:44:47Z")

</div>

The “=” is an accepted alternative Lua-style syntax, but you’re correct that the example is wrong as this syntax only accepts string literals. Thanks, we’ll fix that 🙏

If you’re already using the latest version, can you open an issue on the Github repo please? It seems that you removed the type check and it worked, so please post that there too and we’ll look to fix it.
