-
-
Notifications
You must be signed in to change notification settings - Fork 215
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
RealTime Client not working - getting not_allowed_token_type error #466
Comments
Another thing I tried was following this Intro to Socket Mode I switched socket mode on at my app and created an But still getting |
I believe you need a RTM token for RTM clients and there's no way to obtain it for new apps without OAuth v1 and a classic app. Per https://api.slack.com/rtm:
Socket mode feature request is #414.
|
Thanks, I suggest to clarify in documentation. It was unclear to me. I would add two things to clarify:
What was confusing to me there was no mention at all for the legacy/now socket mode. Specially as someone who is unfamiliar with Slack. For me, after reading RealTime Client](https://github.com/slack-ruby/slack-ruby-client#realtime-client) it was a straight procedure which just didn't work. I thought I was doing something wrong. More so I wasn't aware there is a distinction between old legacy mode to new socket mode- I suggest make that clear in the Thanks Oh and if it helps other people, that's what I ended up doing: require 'em-websocket'
require 'faye/websocket'
require 'http' # can use any rest client gem
# Notice!! this is an APP-LEVEL-TOKEN with only connections:write permission (see https://api.slack.com/authentication/token-types#app)
slack_app_level_token = 'xapp-1-abcd-123456.....'
# get web-socket link:
get_ws_link_api_url = 'https://slack.com/api/apps.connections.open'
ws_socket_link = HTTP.headers('Authorization': "Bearer #{slack_app_level_token}").post(get_ws_link_api_url, form: {}).dig('url')
EM.run do
ws = Faye::WebSocket::Client.new(ws_socket_link)
ws.on :open do |event|
p [:open]
ws.send('Hello, world!')
end
ws.on :message do |event|
p [:message, event.data]
end
ws.on :error do |error|
puts "error: #{error}"
# puts "error: #{error} onerror: #{error}, #{error.inspect}, #{error.backtrace}"
end
ws.on :close do |event|
p [:close, event.code, event.reason]
ws = nil
end
EM::Timer.new(5*60) do # set a timer for 5 minutes (300 seconds)
puts "WebSocket timed out"
ws.close(1000, "WebSocket timed out") # close the WebSocket connection
EM.stop
end
end |
Thanks. I'll close this. Care to PR the suggested doc changes? PS: The immediate problem you'll run into EventMachine is that it does not maintain your websocket alive. We struggled with this in #257 and related issues. So I wouldn't put the code above in production. |
Calling
client.start!
causesnot_allowed_token_type
error when trying to start a realtime clientTo reproduce just follow the readme example
Trying to start client but getting error:
If it helps I can use token to post messages using
curl
:Am I missing something?
The text was updated successfully, but these errors were encountered: