public override async Task <InboxAdapterUserCredential> AuthGetCredentialAsync(string code, string redirectUrl, CancellationToken cancel = default) { using (SlackApi tmpApi = new SlackApi(this.AppCredential.ClientId._NullCheck(), this.AppCredential.ClientSecret._NullCheck())) { SlackApi.AccessToken token = await tmpApi.AuthGetAccessTokenAsync(code, redirectUrl, cancel); return(new InboxAdapterUserCredential { AccessToken = token.access_token }); } }
static async Task Inbox_SlackTestAsync() { string accessToken = "_________________"; if (false) { using (SlackApi slack = new SlackApi("687264585408.675851234162", "_________________")) { if (false) { //string scope = "channels:read groups:read im:read mpim:read channels:history groups:history im:history mpim:history users:read users.profile:read"; string scope = Consts.OAuthScopes.Slack_Client; string url = slack.AuthGenerateAuthorizeUrl(Consts.OAuthScopes.Slack_Client, "https://www.google.com/"); url._Print(); } else { var token = await slack.AuthGetAccessTokenAsync("_________________", null); token._PrintAsJson(); } } } else { using (SlackApi slack = new SlackApi("687264585408.675851234162", "_________________", accessToken)) { //var channels = await slack.GetChannelsListAsync(); //await slack.GetConversationsListAsync(); using (WebSocket ws = await slack.RealtimeConnectAsync()) { using (var st = ws.GetStream()) { while (true) { IReadOnlyList <ReadOnlyMemory <byte> > segments = await st.FastReceiveAsync(); foreach (ReadOnlyMemory <byte> mem in segments) { string str = mem._GetString_Ascii(); str._Print(); } } } } } } }