Love2D with Nakama


I’m trying do use Nakama with Love2D game engine.
I read the Lua Client docs but I’m kind of stuck.

I use the last Nakama Server but I got a Unable to login and no new device is visible on my Nakama Console.

local function device_login(client)
	local body = nakama.create_api_account_device(love2d.uuid())
	local result = nakama.authenticate_device(client, body, true)
    if result then
        if result.token then
            nakama.set_bearer_token(client, result.token)
            return true
	print("Unable to login")
	return false

function love.load()
    --load nakama
	local config = {
        host = "",
        port = 7350,
        use_ssl = false,
        username = "defaultkey",
        password = "",
        engine = love2d,
        timeout = 10,
	local client = nakama.create_client(config)


EDIT! The current output of the authenticate_device is equal to nil and I still don’t get where to correct this

Hi @shioridotdev welcome to the forum.

Please can you check that you’re getting a valid value for body which you’re passing to the authenticate_device function.

Thanks for the reply,

For the output of the body before passing it to the authenticate_device it’s

{ ["id"] = 5c251fc8-5643-4403-c433-04ed336b0dff,}

Here is another output
As I continue the debugging, seems like I got a little issue with coroutine.

Without coroutine

authenticate_device() with callback
DATA    {"id":"dd5cb811-8c7c-4f83-cfbc-04ed336b0dff"}
Unable to login

With coroutine

authenticate_device() with coroutine
DATA    {"id":"b417483f-bad6-44e9-c413-04ed336b0dff"}

My program doesn’t go inside the fn function in async.lua arround line 12

		results = { ... }
		if state == "YIELDED" then
			local ok, err = coroutine.resume(co)
			if not ok then print(err) end
			state = "DONE"
	end, ...)
	if state == "RUNNING" then
		state = "YIELDED"
		state = "DONE"		-- not really needed

EDIT 2 : I set up a github repo to checkout the whole code if necessary
nakama-love2d repository

Hello there !

Still in need of some hint.
Trying to work around it but still same issue.

@shioridotdev I’m a bit lost on where you’re stuck. Would you be able to summarize it again?


Thanks for your answer, I’m sorry for being late in the respond and sorry if my first post was not too clear, I will try to translate better my issue in English, feel free to ask me again if I didn’t write it properly again.

What I’m trying to do:
Setting up a client base on Love2D game engine (LUA language) and make it workable with Nakama Server.

What is currently working:
Client start properly and the log are those next few lines

authenticate_device() with coroutine
DATA    {"id":"b417483f-bad6-44e9-c413-04ed336b0dff"}

What is not working:
No new user/device are register in the Nakama Server

How to reproduce it
I set up a GIT repository that you can use to see the whole code.
nakama-love2d repository

Version use
Love2d v11.3
Nakama v3.9.0


I’m coming back on this thread to get some update about my issue that is still

Currently looking for where it come from.

If anyone got some hint on it I’m listening.

Thanks for your time.

Hi @shioridotdev

do you get any errors in the server when trying to authenticate?

Hello @ftkg

The only last docker log I have is the startup message:

{"level":"info","ts":"2022-02-28T08:04:08.298Z","caller":"main.go:175","msg":"Startup done"}

Thanks for your qucik reply

@shioridotdev Can you capture the error that comes back from authenticate_device() and print it out? You can do that using the pcall() function.


Can you guide me for using the pcall function?
When trying to use it I got this as output:

false   attempt to call a table value

Also on my previous message you got the github page for the project if you got time to look on it.


See some examples here: nakama-project-template/daily_rewards.lua at master · heroiclabs/nakama-project-template · GitHub

Thanks for the reply, will look on it and get back here for the log.


Just a fallback on the current issue.
I can’t seems to found any error output on the nakama log.


Sorry to push again this post but I still don’t found any solution to my issue.

Thanks a lot for your time

Can you post your new code with the pcall() function?

Sorry I got issue and couldn’t continue to look up it.

I got the following error while doing an http request :

authenticate_email() with coroutine
HTTP    POST    http://localhost:7350/v2/account/authenticate/email?username=britzl&create=true
DATA    {"email":"","password":"foobar123"}
{"code":3, "message":"invalid character 'P' looking for beginning of value"}    400     table: 0x010de8ac28     HTTP/1.1 400 Bad Request