Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rtm.connect API call fails with not_allowed_token_type error code #958

Closed
mr185306 opened this issue Feb 16, 2021 · 6 comments
Closed

rtm.connect API call fails with not_allowed_token_type error code #958

mr185306 opened this issue Feb 16, 2021 · 6 comments
Labels
question M-T: User needs support to use the project rtm-client Version: 3x

Comments

@mr185306
Copy link

mr185306 commented Feb 16, 2021

Hi,

I had made a simple SlackAPI bot for my work environment. It scrapes data and allowed us to query the bot using '.flumecheck' which would return the most recently scraped values to that slack channel. No changes have been made to the code itself so I was wondering if an update had been made to the API itself that would mean the following code is now outdated:

########## Code Snippet ##########

@RTMClient.run_on(event='message')
async def checkFunction(**payload):
    print('The check function was called')
    data = payload['data']
    web_client = payload['web_client']
    if data['text'].upper().startswith('.FLUMECHECK'):
        channel_id = data['channel']
        user = data['user']
        text = file_read()
        message = [{ "color" : '#30fc03', "text" :'here is the data <@' + str(user) + '> \n ' + text[0] + text[1] }]
        print(channel_id)
        web_client.chat_postMessage(channel=channel_id, attachments =message) 

def main():
    slack_token = "(slack token removed)"

    rtm_client = RTMClient(token=slack_token,connect_method='rtm.start')
    retrieveData()
    rtm_client.start()

if __name__ == "__main__":
    main() 

########## Code Snippet ##########

Now when anyone sends the '.flumecheck' query, nothing is returned. Also there is no error returned by the script itself. If anyone could point me in the right direction that would be appreciated.

@seratch seratch added question M-T: User needs support to use the project rtm-client Version: 3x and removed untriaged labels Feb 16, 2021
@seratch
Copy link
Member

seratch commented Feb 16, 2021

Hi @mr185306, can you provide more detailed information such as error code, stacktrace etc? I suggest enabling debug logging to see what's happening in your app.

import logging
logging.basicConfig(
    level=logging.DEBUG,
    format="%(asctime)s.%(msecs)03d %(levelname)s %(pathname)s (%(lineno)s): %(message)s",
    datefmt="%Y-%m-%d %H:%M:%S",
)

@mr185306
Copy link
Author

Hi Thanks for the quick response, apologies for the delayed response this is my work account so just seen. I don't actually have an error but I'll enable debug mode while at work tomorrow and get back to you.

@mr185306
Copy link
Author

mr185306 commented Feb 17, 2021

Hi @seratch Thanks for that ! I enabled debug logging and got the following:

'(470): Received an event: 'err
or' - The request to the Slack API failed.
The server responded with: {'ok': False, 'error': 'not_allowed_token_type'};' 

I thought maybe I was using the wrong token so I switched from using the 'Bot User OAuth Access Token' to using the 'OAuth Access Token' but the I had a different error saying I was missing the scope rtm:stream, which when I look up I saw in some previous issue was caused by using OAuth token instead of Bot User Token. So unsure in which direction to take it.

@seratch
Copy link
Member

seratch commented Feb 17, 2021

@mr185306 As mentioned in the document https://slack.dev/node-slack-sdk/rtm-api

Note: RTM isn’t available for modern scoped apps anymore. We recommend using the Events API and Web API instead. If you need to use RTM (possibly due to corporate firewall limitations), you can do so by creating a legacy scoped app. If you have an existing RTM app, do not update its scopes as it will be updated to a modern scoped app and stop working with RTM.

You need to have a "classic" app and issue a bot token with the settings for utilizing RTM API. You can create a new classic app from this URL.

@mr185306
Copy link
Author

@seratch Ahh Okay got it Ill get to that

@seratch seratch changed the title RTMclient No longer working, No Changes made. rtm.connect API call fails with not_allowed_token_type error code Feb 19, 2021
@seratch
Copy link
Member

seratch commented Feb 19, 2021

As I've provided an answer to this question, let me close this issue. If you have something further to ask/discuss here, please feel free to write in.

@seratch seratch closed this as completed Feb 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question M-T: User needs support to use the project rtm-client Version: 3x
Projects
None yet
Development

No branches or pull requests

2 participants