static async Task Main(string[] args) { var oauthAccessMethod = new OauthAccessMethod("Slack app client ID", "Slack app client secret", "temp auth code") { RedirectUri = "Slack app authorized redirect URL" }; var webClient = await SlackWebClientFactory.CreateWebClient("userId", oauthAccessMethod); var connectionResponse = await webClient.CallApiMethod <ConnectResponse>(new RtmConnectMethod()); var slackClient = new SlackRtmClient(); if (connectionResponse.Ok) { await slackClient.Connect(connectionResponse.Url); slackClient.BindEvent <ReactionAddedEvent>(ReactionAddedCallback); slackClient.BindEvent <ReactionRemovedEvent>(ReactionRemovedCallback); Console.WriteLine("User connected"); } Console.Read(); }
/// <summary> /// Exchange the temporary code for the user's secret token. /// </summary> /// <param name="oauthAccessMethod">OAuth access method options.</param> /// <returns>Client that will allow taking authorized actions on behalf of the user.</returns> private static async Task <SlackWebClient> AuthorizeClient(OauthAccessMethod oauthAccessMethod) { return(await SlackWebClientFactory.CreateWebClient("userId", oauthAccessMethod)); }