slack_chat_api/
oauth_v_2.rs1use crate::Client;
2use crate::ClientResult;
3
4pub struct OauthV2 {
5 pub client: Client,
6}
7
8impl OauthV2 {
9 #[doc(hidden)]
10 pub fn new(client: Client) -> Self {
11 OauthV2 { client }
12 }
13
14 pub async fn oauth_access(
29 &self,
30 client_id: &str,
31 client_secret: &str,
32 code: &str,
33 redirect_uri: &str,
34 ) -> ClientResult<crate::Response<crate::types::DndEndSchema>> {
35 let mut query_args: Vec<(String, String)> = Default::default();
36 if !client_id.is_empty() {
37 query_args.push(("client_id".to_string(), client_id.to_string()));
38 }
39 if !client_secret.is_empty() {
40 query_args.push(("client_secret".to_string(), client_secret.to_string()));
41 }
42 if !code.is_empty() {
43 query_args.push(("code".to_string(), code.to_string()));
44 }
45 if !redirect_uri.is_empty() {
46 query_args.push(("redirect_uri".to_string(), redirect_uri.to_string()));
47 }
48 let query_ = serde_urlencoded::to_string(&query_args).unwrap();
49 let url = self
50 .client
51 .url(&format!("/oauth.v2.access?{}", query_), None);
52 self.client
53 .get(
54 &url,
55 crate::Message {
56 body: None,
57 content_type: None,
58 },
59 )
60 .await
61 }
62}