summaryrefslogtreecommitdiff
path: root/protocols/Slack/src/api/api_oauth.h
blob: cc1c35ae3eeaba85bd295962070a7ce859c67d41 (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
#ifndef _SLACK_API_OAUTH_H_
#define _SLACK_API_OAUTH_H_

class OAuhtAccessRequest : public HttpRequest
{
public:
	OAuhtAccessRequest(const char *code, const char *state = NULL) :
		HttpRequest(HttpMethod::HttpPost, SLACK_API_URL "/oauth.access")
	{
		Headers
			<< CHAR_VALUE("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
		Content
			<< CHAR_VALUE("client_id", SLACK_CLIENT_ID)
			<< CHAR_VALUE("client_secret", SLACK_CLIENT_SECRET)
			<< ENCODED_VALUE("code", code)
			<< ENCODED_VALUE("state", state)
			<< ENCODED_VALUE("redirect_uri", SLACK_REDIRECT_URL);
	}
};

class AuthRevokeRequest : public HttpRequest
{
public:
	AuthRevokeRequest(const char *token) :
		HttpRequest(HttpMethod::HttpPost, SLACK_API_URL "/auth.revoke")
	{
		timeout = 1; // in seconds?
		Headers
			<< CHAR_VALUE("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
		Content
			<< CHAR_VALUE("token", token);
	}
};

#endif //_SLACK_API_OAUTH_H_