Google Play Games Token (502 error)

Hello!

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]: 
github.com/heroiclabs/nakama/v3/social.(*Client).CheckGoogleToken(0xc0000b0640, {0x2a1d380, 0xc000d65380}, {0xc001156000, 0x362}) github.com/heroiclabs/nakama/v3@v3.21.1/social/social.go:453 +0x20af 
github.com/heroiclabs/nakama/v3/server.AuthenticateGoogle({0x2a1d380, 0xc000d65380}, 0x0?, 0xc000575768?, 0x0?, {0xc001156000?, 0x0?}, {0xc00114a018, 0x7}, 0x1) 
github.com/heroiclabs/nakama/v3@v3.21.1/server/core_authenticate.go:630 +0x6f 
github.com/heroiclabs/nakama/v3/server.(*ApiServer).AuthenticateGoogle(0xc001496200, {0x2a1d380?, 0xc000d65380}, 0xc000976c30) 
github.com/heroiclabs/nakama/v3@v3.21.1/server/api_authenticate.go:600 +0x4c5 
github.com/heroiclabs/nakama/v3/apigrpc._Nakama_AuthenticateGoogle_Handler.func1({0x2a1d380, 0xc000d65380}, {0x2143540?, 0xc000976c30}) 
github.com/heroiclabs/nakama/v3@v3.21.1/apigrpc/apigrpc_grpc.pb.go:1669 +0x72 
github.com/heroiclabs/nakama/v3/server.StartApiServer.func1({0x2a1d380?, 0xc000d650e0?}, {0x2143540, 0xc000976c30}, 0xc0008139c0?, 0xc001047290) 
github.com/heroiclabs/nakama/v3@v3.21.1/server/api.go:107 +0x8f 
github.com/heroiclabs/nakama/v3/apigrpc._Nakama_AuthenticateGoogle_Handler({0x222e220?, 0xc001496200}, {0x2a1d380, 0xc000d650e0}, 0xc001698f80, 0xc001491470) 
github.com/heroiclabs/nakama/v3@v3.21.1/apigrpc/apigrpc_grpc.pb.go:1671 +0x135 
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0004fc960, {0x2a1d380, 0xc000d64de0}, {0x2a27e60, 0xc000986680}, 0xc000e3e7e0, 0xc0014915c0, 0x35c8988, 0x0) 
google.golang.org/grpc@v1.60.0/server.go:1372 +0xe03 google.golang.org/grpc.(*Server).handleStream(0xc0004fc960, {0x2a27e60, 0xc000986680}, 0xc000e3e7e0) 
google.golang.org/grpc@v1.60.0/server.go:1783 +0xfec google.golang.org/grpc.(*Server).serveStreams.func2.1() google.golang.org/grpc@v1.60.0/server.go:1016 +0x59 created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 227 
google.golang.org/grpc@v1.60.0/server.go:1027 +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.

Best.

1 Like