slackapi / python-slack-sdk

Slack Developer Kit for Python
https://slack.dev/python-slack-sdk/
MIT License
3.83k stars 839 forks source link

Failing auth_test for token - what could be the reasons? #1524

Closed saurabh0719 closed 1 week ago

saurabh0719 commented 1 month ago

(Describe your issue and goal here)

When getting my customers to authorise with my slack bot, I call the auth_test method with the newly obtained token

        try:
            response = client.auth_test(token=token)
        except SlackApiError as e:
            self.log.error(
                status="failed_to_complete_auth_test", exception=e.response["error"]
            )

Slack sent us back an account_inactive error. Going by slack's documentation

Authentication token is for a deleted user or workspace when using a bot token.

However our customer is active on their slack workspace. Also this flow seems to be working for all our other customers, and our own account as well. Can you help me with what could be the list of all possible reasons to get this error? I opened a ticket on your support tool previously regarding the same.

Reproducible in:

pip freeze | grep slack
python --version
sw_vers && uname -v # or `ver`

The Slack SDK version

slack-sdk==3.19.5

Python runtime version

Python 3.8.13

OS info

6.5.0-41-generic #41~22.04.2-Ubuntu SMP PREEMPT_DYNAMIC Mon Jun  3 11:32:55 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
seratch commented 1 month ago

Hi @saurabh0719, thanks for asking the question.

A possible cause of the error could be that the token your database stores is outdated for some reason (e.g., the customer reinstalled your app with a different set of scopes and your app failed to store the new one, or your datastore actually stores newer tokens but your authorize code in the bolt app fails to fetch them).

When a bot token is "inactive" and your app's database does not have any other tokens associated with the workspace, there's nothing you can do on your app's side. The only approach to resolve this is to ask your customer to reinstall the app. We won't be able to guess further. I hope this helps and your customer can use your app without any issues soon.

github-actions[bot] commented 3 weeks ago

👋 It looks like this issue has been open for 30 days with no activity. We'll mark this as stale for now, and wait 10 days for an update or for further comment before closing this issue out. If you think this issue needs to be prioritized, please comment to get the thread going again! Maintainers also review issues marked as stale on a regular basis and comment or adjust status if the issue needs to be reprioritized.

github-actions[bot] commented 1 week ago

As this issue has been inactive for more than one month, we will be closing it. Thank you to all the participants! If you would like to raise a related issue, please create a new issue which includes your specific details and references this issue number.