public async Task <OauthReponse> OauthAccess(string clientId, string clientSecret, string code)
        {
            UrlQueryString url = new UrlQueryString("https://slack.com/api/oauth.access");

            url.Add("client_id", clientId);
            url.Add("client_secret", clientSecret);
            url.Add("code", code);

            try
            {
                string response = await client.GetStringAsync(url);

                OauthReponse?oauthResponse = JsonSerializer.Deserialize <OauthReponse>(response);

                if (oauthResponse == null || !oauthResponse.Ok)
                {
                    throw new WebException("Slack error: " + response);
                }

                return(oauthResponse);
            }
            catch (Exception ex)
            {
                ex.AddData("code", code);
                throw;
            }
        }
Exemple #2
0
 /// <summary>
 /// Sets the URL of the page to display, causing the browser to navigate to or refresh this page.
 /// </summary>
 /// <param name="url"></param>
 public void SetUrl(string url)
 {
     this.HtmlPageUrl = string.IsNullOrEmpty(url)
                         ? null
                         : new Uri(string.Format("{0}?{1}", url, UrlQueryString.Build(new { lang = InstalledLocales.Instance.Selected.Culture })));
 }