summaryrefslogtreecommitdiff
path: root/protocols/Steam/src/api/authorization.h
blob: e7b2ee8c392244b35624c1d434e02b3d3ff116ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef _STEAM_REQUEST_AUTHORIZATION_H_
#define _STEAM_REQUEST_AUTHORIZATION_H_

class AuthorizationRequest : public HttpRequest
{
public:
	AuthorizationRequest(const char *username, const char *password, const char *timestamp) :
		HttpRequest(REQUEST_POST, STEAM_WEB_URL "/mobilelogin/dologin")
	{
		flags = NLHRF_HTTP11 | NLHRF_SSL | NLHRF_NODUMP;

		char data[1024];
		mir_snprintf(data, SIZEOF(data),
			"username=%s&password=%s&oauth_client_id=3638BFB1&oauth_scope=read_profile write_profile read_client write_client&captchagid=-1&rsatimestamp=%s",
			ptrA(mir_urlEncode(username)),
			ptrA(mir_urlEncode(password)),
			timestamp);

		SetData(data, strlen(data));
		AddHeader("Content-Type", "application/x-www-form-urlencoded");
	}

	AuthorizationRequest(const char *username, const char *password, const char *timestamp, const char *guardCode) :
		HttpRequest(REQUEST_POST, STEAM_WEB_URL "/mobilelogin/dologin")
	{
		flags = NLHRF_HTTP11 | NLHRF_SSL | NLHRF_NODUMP;

		char data[1024];
		mir_snprintf(data, SIZEOF(data),
			"username=%s&password=%s&emailauth=%s&loginfriendlyname=MirandaNG&oauth_client_id=3638BFB1&oauth_scope=read_profile write_profile read_client write_client&captchagid=-1&rsatimestamp=%s",
			ptrA(mir_urlEncode(username)),
			ptrA(mir_urlEncode(password)),
			guardCode,
			timestamp);

		SetData(data, strlen(data));
		AddHeader("Content-Type", "application/x-www-form-urlencoded");
	}

	AuthorizationRequest(const char *username, const char *password, const char *timestamp, const char *captchaId, const char *captchaText) :
		HttpRequest(REQUEST_POST, STEAM_WEB_URL "/mobilelogin/dologin")
	{
		flags = NLHRF_HTTP11 | NLHRF_SSL | NLHRF_NODUMP;

		char data[1024];
		mir_snprintf(data, SIZEOF(data),
			"username=%s&password=%s&emailauth=&captchagid=%s&captcha_text=%s&oauth_client_id=3638BFB1&oauth_scope=read_profile write_profile read_client write_client&rsatimestamp=%s",
			ptrA(mir_urlEncode(username)),
			ptrA(mir_urlEncode(password)),
			captchaId,
			ptrA(mir_urlEncode(captchaText)),
			timestamp);

		SetData(data, strlen(data));
		AddHeader("Content-Type", "application/x-www-form-urlencoded");
	}
};

#endif //_STEAM_REQUEST_AUTHORIZATION_H_