Player authorization with a third party?


Hey all -

I’m in the process of starting a new game project and stumbled onto Defold by chance (was originally planning on using a custom HTML5 solution). Since I have a soft spot for Lua, I figured I’d dig through the docs here and see if it would meet my requirements.

It seems it meets most of them… except one. I have the requirement to be able to log players in using an OAuth2 service… specifically, Twitch. Seeing as Defold does not allow for WebView on Desktop, I’m not sure if Defold would allow me to solve this problem.

I can’t make a simple HTTP request because I need to be able to load up a browser, the player will have to specifically allow permission to my game, and then the browser is redirected back to my app where I can get the auth token from the url (I’m sure most here know how OAuth works, haha). I don’t see how I can do this with Defold since 1) I can’t embed a WebView, and 2) I can’t read the return URL from a url I opened with (I believe that’s call).

Enough rambling – Is something like Twitch (or any other service) OAuth something that can be achieved with Defold? As I’ve said, I’m not seeing any solution… at least not out of the box. I assume I could always open a WebSocket connection to my server, open the browser or OAuth, redirect to my server, and then broadcast that token back to the game… that feels like a big workaround, though lol. I also know I could use a custom URL scheme but I understand that feature has been removed from later versions of OSX.

Any insight would be greatly appreciated. This seems like an engine I’d really enjoy (again, soft spot for Lua) but I wouldn’t be able to move forward without being able to solve this.

1 Like


You’re right that there is no webview support on desktop yet. It was actually requested recently as well so we might look into it soon. Our plan is to also move the webview to a native extension which would open up for community driven initiatives to fix it. And someone could already now create a native extension specifically for webview support on desktop.



Hey there, I was recently thinking on how to solve this. It may be a crazy solution. It requires the native Defold application (Desktop, iOS, Android) to spawn an http server, and listen for a specific URL.

Considering that you have control over the server-side implementation, the final URL of the authentication service could make a request to the local server created by the native Defold application to finish the process.

Does that sound crazy? Is it possible to spawn a http server inside Defold?



Yes it is possible:
Require c/c++ knowledge but I believe almost every embeddable http server can be implemented.

1 Like