Your code looks like an installation routine for a Slack app using OAuth.
(您的代码看起来像是使用OAuth的Slack应用程序的安装例程。)
But it does not contain a call to get a user profile. (但是它不包含获取用户个人资料的调用。)
To get the profile of a user you can call users.info
and provide the ID of the user you are interested in.
(要获取用户的个人资料,您可以调用users.info
并提供您感兴趣的用户的ID。)
Examples:
(例子:)
response = client.users_info(user=ID_OF_USER)
assert(response)
profile = response['user']['profile']
email = response['user']['profile']['email']
In order to retrieve the user's profile and email address you need these scopes: - users:read - users:read.email
(为了检索用户的个人资料和电子邮件地址,您需要以下范围:-users:read-users:read.email)
The identity scopes are unrelated to the user profile.
(身份范围与用户配置文件无关。)
They are used for the " Sign-in with Slack " approach only, where you can authenticate with a Slack user on a 3rd party web site. (它们仅用于“ 使用Slack登录 ”方法,您可以在其中通过第三方网站上的Slack用户进行身份验证。)
Finally, just to clarify, because this is often misunderstood: You only need to run through the OAuth installation routine once.
(最后,只需澄清一下,因为这常常被误解:您只需要运行一次OAuth安装例程。)
The routine will yield you a token for the workspace, which you can store and use for any further calls to the API for that workspace. (该例程将为您提供工作空间的令牌,您可以将其存储并用于对该工作空间的API的任何其他调用。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…