Google Play Games Token (502 error)


I am using nakama 3.21.1-r3 on heroic cloud to authenticate users through Google Play Games. Client is made with Unity and the Nakama SDK, and Runtime language is Typescript, but that’s probably not important for this post.

While working my way through how Google Play Games / Google Cloud with Oauth2 etc. were supposed to be done, I wanted to confirm that things where correctly working together. (Nakama vs Google, is it actually checking the correct token).

So I figured for testing this, that I would make the device able to attempt using AuthenticateGoogleAsync(), but instead of the actual token, a single character in the token is changed to something different. Maybe it’s completely dumb, but this was just my way of trying to verify that things were working, and I was probably hoping to see something like ‘Can’t Authenticate’.

Whenever I pass the fake token into AuthenticateGoogleAsync, my dashboard goes into a 502 error, and the snippet below is what’s being logged on the server. Seems to cause the server instance to restart and not respond for a while. I might be overthinking things, but could someone potentially cause this to the server? Or am I missing something that I should be doing to handle this?

I want to mention that doing a regular AuthenticateGoogleAsync with the actual token received works perfectly fine and as intended.

No custom runtime code or hooks are used for any of this, only what the SDK offers to authenticate with Google.

2024-04-05T08:56:02.607Z panic: interface conversion: 
jwt.Claims is nil, not jwt.MapClaims goroutine 260 [running]:*Client).CheckGoogleToken(0xc0000b0640, {0x2a1d380, 0xc000d65380}, {0xc001156000, 0x362}) +0x20af{0x2a1d380, 0xc000d65380}, 0x0?, 0xc000575768?, 0x0?, {0xc001156000?, 0x0?}, {0xc00114a018, 0x7}, 0x1) +0x6f*ApiServer).AuthenticateGoogle(0xc001496200, {0x2a1d380?, 0xc000d65380}, 0xc000976c30) +0x4c5{0x2a1d380, 0xc000d65380}, {0x2143540?, 0xc000976c30}) +0x72{0x2a1d380?, 0xc000d650e0?}, {0x2143540, 0xc000976c30}, 0xc0008139c0?, 0xc001047290) +0x8f{0x222e220?, 0xc001496200}, {0x2a1d380, 0xc000d650e0}, 0xc001698f80, 0xc001491470) +0x135*Server).processUnaryRPC(0xc0004fc960, {0x2a1d380, 0xc000d64de0}, {0x2a27e60, 0xc000986680}, 0xc000e3e7e0, 0xc0014915c0, 0x35c8988, 0x0) +0xe03*Server).handleStream(0xc0004fc960, {0x2a27e60, 0xc000986680}, 0xc000e3e7e0) +0xfec*Server).serveStreams.func2.1() +0x59 created by*Server).serveStreams.func2 in goroutine 227 +0x115

Hello @Smaskotan, thank you for reporting this, the server should definitely not panic if the token is invalid, we’ll fix it and make it part of our next Nakama release.


1 Like