Why i am getting "error": "user_not_found" whenever i call "users.profile.get" slack API?

809 views Asked by At

So, I created the slack bot and it was working completely fine but, When I distributed the slack bot app to another workspace I started facing the "user not found" error on API call of "users_profile_get" as I have also cross-checked the required scopes for this API, user_id, and access token and they are completely fine but still API call returns user not found. I need your help guys on it as I am missing something while distributing the app or Is there any other problem? There is also One strange thing that I can call "chat.postMessage" API of slack and it runs successfully.

result = app.client.users_profile_get(user=slack_id)

While calling this API, I am getting error :

{
    "ok": false,
    "error": "user_not_found"
}
1

There are 1 answers

0
sandra On

Distributed apps cannot call API methods across Workspaces, so you would need to make sure that you're using an API token that belongs to the same Workspace that the user belongs to. You can double check by passing your token to the https://api.slack.com/methods/auth.test method. to retrieve tokens from other workspaces make sure you have enabled OAuth 2.0 (https://api.slack.com/authentication/oauth-v2.