Skip to content

Instantly share code, notes, and snippets.

@sachinr
Last active March 8, 2017 02:54
Show Gist options
  • Save sachinr/c0dc018d161e6c011b5f3788f86a6494 to your computer and use it in GitHub Desktop.
Save sachinr/c0dc018d161e6c011b5f3788f86a6494 to your computer and use it in GitHub Desktop.
Slack app for creating webhooks
require 'sinatra'
require 'rest-client'
require 'json'
get '/oauth' do
if params['code']
options = {
client_id: ENV['SLACK_CLIENT_ID'],
client_secret: ENV['SLACK_CLIENT_SECRET'],
code: params['code']
}
res = RestClient.post 'https://slack.com/api/oauth.access', options
json = JSON.parse(res)
if json["incoming_webhook"]
p json["incoming_webhook"]["configuration_url"]
else
"Oh no! Something went wrong"
end
end
end
source 'https://rubygems.org'
ruby "2.3.1"
gem 'sinatra'
gem 'rest-client'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment