question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue Connecting to Slack API with WebClient

See original GitHub issue

I am trying to pull an active list of users for our slack workspace to use in our IT Department. The goal is to have a webapp that we can see everyone in our applications. I get the following error when trying to connect to the API by using the token from the slack bot I had to make:

Python runtime version

python@3.9

OS info

macOS/Linux

Expected result:

To get a list/dictionary of active users

Actual result:

Traceback (most recent call last):
  File "/Users/johnmichaelmizerany/Desktop/UserDashboard/slack.py", line 15, in <module>
    result = client.users_list()
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/slack_sdk/web/client.py", line 2249, in users_list
    return self.api_call("users.list", http_verb="GET", params=kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/slack_sdk/web/base_client.py", line 135, in api_call
    return self._sync_send(api_url=api_url, req_args=req_args)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/slack_sdk/web/base_client.py", line 171, in _sync_send
    return self._urllib_api_call(
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/slack_sdk/web/base_client.py", line 284, in _urllib_api_call
    response = self._perform_urllib_http_request(url=url, args=request_args)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/slack_sdk/web/base_client.py", line 437, in _perform_urllib_http_request
    raise err
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/slack_sdk/web/base_client.py", line 411, in _perform_urllib_http_request
    resp = urlopen(  # skipcq: BAN-B310
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 214, in urlopen
    return opener.open(url, data, timeout)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 517, in open
    response = self._open(req, data)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 534, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 494, in _call_chain
    result = func(*args)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 1389, in https_open
    return self.do_open(http.client.HTTPSConnection, req,
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 1349, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)>

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
seratchcommented, May 7, 2021

@jmmiz I’m not 100% sure if this helps you out but what happens if you run the following script after pip install -U slack-sdk certifi?

# pip install -U slack-sdk certifi
import certifi, logging, os, ssl
from slack_sdk import WebClient

logging.basicConfig(level=logging.DEBUG)
ssl_context = ssl.create_default_context(cafile=certifi.where())
client = WebClient(ssl=ssl_context)
client.api_test()
1reaction
jmmizcommented, May 8, 2021

Yes! Thank you for your help @seratch

Read more comments on GitHub >

github_iconTop Results From Across the Web

Web API - Slack Platform Developer Tools
The @slack/web-api package contains a simple, convenient, and configurable HTTP client for making requests to Slack's Web API. Use it in your app...
Read more >
Using the Slack Web API
The Web API is an RPC-style collection of methods that either yield information about Slack workspaces or allows your app to enact change...
Read more >
Webclient is failing the events to process · Issue #792 - GitHub
If your issue is caused only in web API calls, are you observing any errors returned from Slack API for Web API calls...
Read more >
Using slack API: "Module slack has no attribute WebClient "
Using slack API: "Module slack has no attribute WebClient " · 1. The code looks correct. Are you sure you have the correct...
Read more >
403 [Forbidden] while connecting to slack web client : Forums
Another possibility is that the Client has not been correctly authenticated so that the 403 is, in fact, coming from the Slack API...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found