【发布时间】:2018-12-24 05:55:16
【问题描述】:
当用户使用登录 Slack 按钮登录 Slack 时,我们如何为他添加更多范围/权限。我在我的 Slack 应用程序的 Outh 权限/范围中添加了范围。它适用于主要所有者,但不适用于其他用户。 我有一个类似的问题here。我想我知道我必须添加权限,但无法弄清楚如何。我尝试将其添加到使用 Slack 按钮登录的初始 oauth 流程中,但它说我不允许将其他范围与 identity.basic 一起使用。
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<a href="https://slack.com/oauth/authorize?scope=identity.basic,identity.email,identity.team,identity.avatar&client_id=373568302675.374024189699">
<img alt="Sign in with Slack" height="40" width="172" src="https://platform.slack-edge.com/img/sign_in_with_slack.png"
srcset="https://platform.slack-edge.com/img/sign_in_with_slack.png 1x, https://platform.slack-edge.com/img/sign_in_with_slack@2x.png 2x" />
</a>
</div>
</div>
谁能告诉我应该在哪里为非主要所有者的用户添加权限?
我在cshtml上又做了一个按钮如下:
<input type="button" value="Authenticate again to send Message" class="btn btn-warning" onclick="location.href = 'https://slack.com/oauth/authorize?scope=incoming-webhook,im:write,chat:write:user&client_id=373568302675.374024189699'"/>
然后单击它会导致与使用 Slack 登录相同的功能,如下所示:
public SlackAuthToken GetAccessToken(ProgramParameter startParam, string clientId, string clientSecret, string code)
{
using (var client = new WebClient())
{
string apiUrl = GetApiUrl(startParam);
string url = apiUrl + "/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;
}
}
【问题讨论】: