How to get a slack user by email using users.info API?
Solution 1
Yes!
https://slack.com/api/users.lookupByEmail
Using this we can find a user if email id is available.
More : https://api.slack.com/methods/users.lookupByEmail
Solution 2
Currently you can only look up users with users.info
by their ID.
An alternative solution to your problem would be to call users.list and filter within your client by the profile.email
for whichever email you're looking for.
Solution 3
An undocumented API can do this job: https://slack.com/api/auth.findUser?team=&email=&token=xoxp-XXXXXXXXX
Solution 4
If this is being done on behalf of a Slack slash command, one can configure the command to expand @username
, #channels
, etc...
This can be done under the command section of the Slack app. See the following screenshot:
Solution 5
This was useful for me.
My setup: I am part of an enterprise, so the legacy token
does not have users:read.email
scope to it.
Solution: I created an app with users:read.email
scope and other scopes needed. Got the app approved from my admin, installed the app to my workspace, retrieved the OAuth token, used it with https://slack.com/api/users.lookupByEmail
.
Related videos on Youtube
Marco
Worked in the tech field for over 20+ years. Started out learning basic on an Apple IIe then on a TRS-80. Been interested in computer hardware and software my entire life. Consider myself lucky that my hobby as a kid/adult is what I get to do everyday earning a living. You can learn more about me here. ============================================================ Stolen from @Mokubai: First, please put down the chocolate-covered banana and step away from the European currency systems. You may consider how to ask a question.
Updated on July 09, 2022Comments
-
Marco almost 2 years
I'm trying to use Slack's
users.info
API to retrieve users information, but I need to find users by email, is there a way to do that? -
Konstantin Komelin over 3 yearsThanks. Here is a regular expression to find and parse the escaped usernames:
\<@([^\|]+)\|([^\>]+)\>