Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting not_authed slack error on web api call though token is passed

I have successfully added an application in slack api with the permission scope set administer the teams:

I have generated the token from Legacy token generator And I am making a api call with the following information from postman.

endpoint: https://slack.com/api/users.list

method:GET

Headers:

key=token

value=token generated

Its returning me the following Response

{
  "ok": false,
  "error": "not_authed"
}

Trying the same things with curl is working but with POST method and does not works on GET method

curl -X POST https://slack.com/api/users.list --data "token=codehere"

Where exactly am I going wrong.

like image 601
Tara Prasad Gurung Avatar asked Apr 21 '17 11:04

Tara Prasad Gurung


People also ask

How do I authenticate slack API?

Authenticate your Web API requests by providing a bearer token, which identifies a single user, bot user, or workspace-application relationship. Register your application with Slack to obtain credentials for use with our OAuth 2.0 implementation, which allows you to negotiate tokens on behalf of users and workspaces.

How do I get my slack API token?

Visit the App Directory at my.slack.com/apps/manage on your desktop. Click Edit configuration next to the integration. On the configuration page, click Regenerate below the current token. This is the new token you can use anywhere you need it.

How do I create API call in slack?

There are two ways for your app to integrate with Slack so that users can initiate and deal with Calls within Slack. One way for a user to initiate your app is via a Slash command—for example, by typing /mycallapp into the message composer. The other way for a user to initiate your app is directly via the Call icon.

What is slack bot token?

Bot tokens represent a bot associated with the app installed in a workspace. Unlike user tokens, they're not tied to a user's identity; they're just tied to your app. Since acting independently allows your app to stay installed even when an installing user is deactivated, using bot tokens is usually for the best.


1 Answers

It works with GET too, but you have to pass the properties as URL parameter, not in the header.

Here is an example for the syntax:

https://slack.com/api/users.list?token=YOURTOKEN 
like image 76
Erik Kalkoken Avatar answered Sep 21 '22 08:09

Erik Kalkoken