Last active
March 8, 2017 02:54
-
-
Save sachinr/c0dc018d161e6c011b5f3788f86a6494 to your computer and use it in GitHub Desktop.
Slack app for creating webhooks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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