Alex Cohen
Alex Cohen

Reputation: 6236

Slack API: How to determine which human user owns a Legacy API token

When using a legacy token in slack I want to determine which user account owns this application. The information is not directly in the bot.info:

{
  "ok": true,
  "bot": {
    "id": "foobar",
    "deleted": false,
    "name": "Slack API Tester",
    "updated": 123456789,
    "app_id": "A123"
  }
}

Could I use the bot.id or bot.app_id objects to find who owns this application? If so which api call would I use.

Upvotes: 1

Views: 190

Answers (1)

Erik Kalkoken
Erik Kalkoken

Reputation: 32854

To determine which user owns any token (incl. legacy token) just call the auth.test endpoint with that token. You will get the user ID and name of the token owner.

Example response from documentation:

{
    "ok": true,
    "url": "https://subarachnoid.slack.com/",
    "team": "Subarachnoid Workspace",
    "user": "grace",
    "team_id": "T12345678",
    "user_id": "W12345678"
}

If you need more info about the user you can call users.info for that user with his ID. Since you are using a legacy token you will have the necessary permissions.

Upvotes: 1

Related Questions