SlackOauth
oauth client library for sinatra
Coverage
- Whether authorized with allowed team
- authorized user's token(slack)
- team id(slack) using the authorization
- team name(slack) using the authorization
Installation
Add this line to your application's Gemfile:
gem 'slack_oauth'
And then execute:
$ bundle
Or install it yourself as:
$ gem install slack_oauth
Usage
require 'sinatra/base'
require 'slack_oauth'
register SlackOauth::Driver
use Rack::Session::Cookie,
:expire_after => 3600,
:secret => 'change'
configure do
set :slack_token, 'xxxxx-xxxxx-xxxx-xxxx'
set :slack_client_id, 'nnnnnn.nnnnn'
set :slack_secret_key, 'xxxxxxxxxxxxxxxxxx'
set :logined_uri, '/'
set :error_uri, '/'
set :slack_redirect_uri, 'http://yourhost:4567/oauth'
set :slack_team, 'your-team' # or nil
set :slack_allowed_teams, ['allowed team']
set :slack_scope, 'identify'
use Rack::Session::Cookie,
:expire_after => 3600,
:secret => 'change'
end
get '/' do
"<html>\n<body>\n\#{(authorized?) ? 'Authorized<br>' : ''}\n<a href=\"\#{get_authentication_url}\">sign in</a>\n</body>\n</html>\n"
end
get '/signout' do
session.clear
end
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/m0cchi/slack_oauth.