Skip to content

Getting nil for id token #46

Description

@amireldor

Hi, this is sort-of-a cross-post with the Defold forums here: https://forum.defold.com/t/need-help-getting-id-token-from-google-play-services/73719

I'm trying to get an id_token from GPGS but I keep getting nil. I've set up the game.project with a client_id and request_id_token=1, but am not sure if I should be adding the Android Credentials client_id or a Web Credential client_id from the GCP panel.

The sign in is successful and I get the id and display name for my sign in, but I need the id_token as well for further authentication against Supabase in my case.

Can you help me with nailing down the cause of this? What might I be doing wrong?

Some quick code from my attempts (I try a silent login, and if that fails, I show a "sign in with Google" button.

function init(self)
	local welcome_gui_url = msg.url("main:/welcome#welcome")

	local function gpgs_callback(self, message_id, message)
	if message_id == gpgs.MSG_SIGN_IN or message_id == gpgs.MSG_SILENT_SIGN_IN then
		if message.status == gpgs.STATUS_SUCCESS then
			print("Signed in")
			print(gpgs.get_id())
			print(gpgs.get_display_name())
			print(gpgs.get_id_token())
			msg.post(welcome_gui_url, "set_sign_in_visibility", { visible = false })
		else
			print("Sign in error!")
			print(message.error)
			msg.post(welcome_gui_url, "set_sign_in_visibility", { visible = true })
		end
		elseif message_id == gpgs.MSG_SIGN_OUT then
			print("Signed out")
			msg.post(welcome_gui_url, "set_sign_in_visibility", { visible = true })
		end
	end


	if gpgs then
		gpgs.set_callback(gpgs_callback)
		gpgs.silent_login()
	else
		print("No gpgs")
		msg.post(welcome_gui_url, "set_sign_in_visibility", { visible = false })
	end
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Size

    None yet

    Score

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions