Only Primary Owner can post Message on Slack

倾然丶 夕夏残阳落幕 提交于 2019-12-02 20:47:32

问题


I have a Slack App and Workspace. Since I am the admin, I can post the message to anyone and to any channel. But, when I am trying to post a message as a different user through an api call using the method chat.postMessage, it gives me the following response.

{"ok":false,"error":"missing_scope","needed":"chat:write:user","provided":"identity.basic,identity.email,identity.avatar,identity.team","warning":"missing_charset","response_metadata":{"warnings":["missing_charset"]}}

I checked the Oauth and Permissions page on Slack and I have the scope as chat:write:user.

I cannot figure out what to do here. Could the auth tokens of the users restricted to be not able to post message and if so , how can I permit them to post message.

I also tried to open a direct message channel usin im.open method from the Slack documentation however, it provides a reasponse as under:

{"ok":false,"error":"missing_scope","needed":"im:write","provided":"identity.basic,identity.email,identity.avatar,identity.team"}

Again, when I check I already have im.open in the scope/permissions.

One last thing that I tried was I made another user as an admin,but it still says the same.

I am attaching my GetAccessToken method here. I think I am requesting the scope in the wrong manner or something like that.

public SlackAuthToken GetAccessToken(string clientId, string clientSecret, string code)
        {
            using (var client = new WebClient())
            {
                string oAuthUrl = "https://slack.com/oauth/authorize?client_id=" + clientId + "&scope=im%3Aread+chat%3Awrite%3Auser";
                var authResponse = client.DownloadString(oAuthUrl);


                string url ="https://xxx.slack.com/api/oauth.access?client_id=" + clientId + "&client_secret=" + clientSecret + "&code=" + code;
                var response = client.DownloadString(url);

                SlackAuthToken slackTest = JsonConvert.DeserializeObject<SlackAuthToken>(response);
                string accessToken = slackTest.AccessToken;
                string urlUserIdentity = "https://slack.com/api/users.identity?token=" + accessToken;
                var responseUser = client.DownloadString(urlUserIdentity);
                SlackAuthToken slack = JsonConvert.DeserializeObject<SlackAuthToken>(responseUser);
                return slackTest;
            }
        }

来源:https://stackoverflow.com/questions/51332569/only-primary-owner-can-post-message-on-slack

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!