purple-googlechat icon indicating copy to clipboard operation
purple-googlechat copied to clipboard

Can't log in from Ubuntu 21.10: Auth Error or Bad Request

Open dreamlayers opened this issue 3 years ago • 2 comments
trafficstars

Yesterday I downloaded the DLLs and successfully logged in from Pidgin 2.14.8 in Windows 10 21H2. After building from source I'm unable to log in from Ubuntu 21.10 using Pidgin 2.14.1-1ubuntu1. Both are 64-bit operating system installs, though Windows is running a 32-bit Pidgin and Linux runs a 64-bit Pidgin. I get either Auth Error or Bad Request. If I get Auth Error, then when I re-enable the account, Pidgin crashes. I tried both last night and now, with same results.

I think I followed https://www.youtube.com/watch?v=hlDhp-eNLMU properly. I found the cookie in a request with URL starting with https://accounts.google.com/o/oauth2/programmatic_auth. The cookie was shown in set-cookie oauth_code=SOMETHING; Path=/; Secure; HttpOnly and I used the SOMETHING between the = and ; not including those delimiters.

Edit, partial success: I've also tried installing pidgin and pidgin-data packages version 2.14.8-1ubuntu1 from Ubuntu 22.04, and starting without a ~/.purple directory, so with a totally clean default configuration, and it still seemed to fail the same way. However, after getting an Auth Error and re-enabling the account, Pidgin did not crash and it logged in successfully! But when I copied the relevant accounts.xml section to my Pidgin configuration, it crashed:

Thread 1 "pidgin" received signal SIGSEGV, Segmentation fault.
0x00007ffff2475c78 in googlechat_get_users_information_internal (ha=0x55555626f200, user_ids=0x5555566df8e0 = {...}, callback=0x7ffff2475adc <googlechat_got_users_information>, userdata=0x0) at googlechat_conversation.c:320
320			member_ids[i] = g_new0(MemberId, 1);
(gdb) print i
$1 = 4294967295

The following seems to be how i becomes negative, and this looks like a bug. Maybe there is good intent behind what it's trying to do, but it seems like this shouldn't be allowed to cause i to become negative. Maybe continue is needed, because after all, if who isn't valid, why store that data?

		if (G_UNLIKELY(!googlechat_is_valid_id(who))) {
			i--;
			n_member_ids--;
		}

googlechat_is_valid_id(who) returns false because who is an alphanumeric string followed by @public.talk.google.com. It seems googlechat_is_valid_id only accepts digits, but why?

Solved: Apparently these are old contacts from XMPP. I tried simply changing the XMPP account to Google Chat, and that caused those invalid contacts. I deleted the XMPP account and created a new one and now it works.

dreamlayers avatar Dec 28 '21 18:12 dreamlayers

Oh! Interesting use case. I never considered someone changing from an XMPP account straight to a Google Chat one. I'll add some extra checks in for that.

Thank you also for the amazing investigations and not just a drive-by "it doesn't work"

Just to check, is everything working ok now that you've started the account from scratch, or is it still not logging in properly?

EionRobb avatar Dec 28 '21 20:12 EionRobb

I was surprised that Pidgin allowed changing the type of accounts. It would be nice if metacontacts could be preserved that way, but it's probably hard to do that correctly.

After all that, it logs in without problems and stays logged in.

I also installed it on a different PC, also in x86_64 Ubuntu 21.10 with pidgin 1:2.14.1-1ubuntu1. There I deleted the XMPP account and created a new account. After I input the OAuth2 code, I got Auth Error, but then when I re-enabled the account it logged in properly and it continues to function properly. Seems like the first login attempt after inputting the OAuth2 code may always cause Auth Error like this, requiring a re-enabling of the account to log in successfully for the first time.

You're welcome, and thank you for making this plugin.

dreamlayers avatar Dec 28 '21 22:12 dreamlayers