class Sorcery::Providers::Slack
This class adds support for OAuth with slack.com.
Attributes
auth_path[RW]
scope[RW]
token_url[RW]
user_info_path[RW]
Public Class Methods
new()
click to toggle source
Calls superclass method
Sorcery::Providers::Base::new
# File lib/sorcery/providers/slack.rb, line 10 def initialize super @scope = 'identity.basic, identity.email' @site = 'https://slack.com/' @user_info_path = 'https://slack.com/api/users.identity' @auth_path = '/oauth/authorize' @token_url = '/api/oauth.access' end
Public Instance Methods
get_user_hash(access_token)
click to toggle source
# File lib/sorcery/providers/slack.rb, line 20 def get_user_hash(access_token) response = access_token.get(user_info_path, params: { token: access_token.token }) auth_hash(access_token).tap do |h| h[:user_info] = JSON.parse(response.body) h[:user_info]['email'] = h[:user_info]['user']['email'] h[:uid] = h[:user_info]['user']['id'] end end
login_url(_params, _session)
click to toggle source
calculates and returns the url to which the user should be redirected, to get authenticated at the external provider's site.
# File lib/sorcery/providers/slack.rb, line 31 def login_url(_params, _session) authorize_url(authorize_url: auth_path) end
process_callback(params, _session)
click to toggle source
tries to login the user from access token
# File lib/sorcery/providers/slack.rb, line 36 def process_callback(params, _session) args = {}.tap do |a| a[:code] = params[:code] if params[:code] end get_access_token(args, token_url: token_url, token_method: :post) end