Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seems like SO have changed something they need all calls to be https #3

Closed
jdd-software opened this issue May 23, 2017 · 1 comment
Closed

Comments

@jdd-software
Copy link

jdd-software commented May 23, 2017

SO returns

"The openid.return_to parameter... does not match the actual URL ",

Switching all http to https in the StackExchangeClient.siteLogin seems to solve this problem

private void siteLogin(String host) throws IOException {
	Response response = httpClient.get("https://" + host + "/users/login?returnurl=" + URLEncoder.encode("https://" + host + "/", "UTF-8"), cookies);
	String fkey = response.parse().select("input[name='fkey']").val();
	response = httpClient.post("https://" + host + "/users/authenticate", cookies, "fkey", fkey, "openid_identifier", openIdProvider);
	Document document = response.parse();

	// confirmation prompt?
	if (response.url().toString().startsWith("https://openid.stackexchange.com/account/prompt")) {
		LOGGER.trace("Confirmation prompt \n" + document.html());
		String session = document.select("input[name='session']").first().val();
		fkey = document.select("input[name='fkey']").first().val();
		Response promptResponse = httpClient.post("https://openid.stackexchange.com/account/prompt/submit", cookies, "session", session, "fkey", fkey);
		document = promptResponse.parse();
		LOGGER.trace("Confirmation prompt response \n" + document.html());
	}

	// when the account doesn't exist on this site, confirm its creation
	if (!document.select("form[action='/users/openidconfirm']").isEmpty()) {
		LOGGER.debug("Account doesn't exist on target site '{}', confirming new account", host);
		String session = document.select("input[name='s']").first().val();
		fkey = document.select("input[name='fkey']").first().val();
		Response newAccountResponse = httpClient.post("https://" + host + "/users/openidconfirm", cookies, "s", session, "fkey", fkey);
		LOGGER.trace("New account confirmation response \n" + newAccountResponse.parse().html());
	}

	// check logged in
	Response checkResponse = httpClient.get("https://" + host + "/users/current", cookies);
	if (checkResponse.parse().getElementsByClass("js-inbox-button").first() == null) {
		LOGGER.debug(response.parse().html());
		throw new IllegalStateException("Unable to login to Stack Exchange.");
	}
}
@Tunaki
Copy link
Owner

Tunaki commented May 23, 2017

Darned Stack Overflow, changing all the thingz and breakin' me codez!

I'll take a look at this (probably in 6 to 8) and release version 1.1.0 with the fix.

@Tunaki Tunaki added the bug label May 23, 2017
@Tunaki Tunaki closed this as completed in e78de30 May 23, 2017
@Tunaki Tunaki added this to the chatexchange-1.1.0 milestone Aug 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants