summaryrefslogtreecommitdiff
path: root/plugins/Dropbox/src/api/account.h
blob: 98ba370abec14d2f6666761438fcc6ee3c6a29db (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
#ifndef _DROPBOX_API_ACCOUNT_H_
#define _DROPBOX_API_ACCOUNT_H_

class GetAccessTokenRequest : public HttpRequest
{
public:
	GetAccessTokenRequest(const char *requestToken) :
		HttpRequest(REQUEST_POST, DROPBOX_API_OLD "/oauth2/token")
	{
		AddHeader("Content-Type", "application/x-www-form-urlencoded");

		CMStringA data(CMStringDataFormat::FORMAT,
			"client_id=%s&client_secret=%s&grant_type=authorization_code&code=%s",
			DROPBOX_APP_KEY, DROPBOX_API_SECRET, requestToken);
		SetData(data.GetBuffer(), data.GetLength());
	}
};

class DisableAccessTokenRequest : public HttpRequest
{
public:
	DisableAccessTokenRequest() :
		HttpRequest(REQUEST_POST, DROPBOX_API_OLD "/disable_access_token")
	{
	}
};

class GetCurrentAccountRequest : public HttpRequest
{
public:
	GetCurrentAccountRequest(const char *token) :
		HttpRequest(REQUEST_POST, DROPBOX_API_RPC "/users/get_current_account")
	{
		AddBearerAuthHeader(token);
	}
};

#endif //_DROPBOX_API_ACCOUNT_H_