Module: OmniAuth::Slack

Defined in:
lib/omniauth-slack/slack.rb,
lib/omniauth-slack/version.rb,
lib/omniauth-slack/refinements.rb,
lib/omniauth-slack/oauth2/client.rb,
lib/omniauth-slack/omniauth/auth_hash.rb,
lib/omniauth-slack/oauth2/access_token.rb,
lib/omniauth-slack/debug.rb

Defined Under Namespace

Modules: ArrayRefinements, CallerMethodName, Debug, OAuth2, OAuth2Refinements, StringRefinements Classes: AuthHash, VerifySlackSignature

Constant Summary collapse

VERSION =
"2.5.0"

Class Method Summary collapse

Class Method Details

.build_access_token(client_id, client_key, token_string_or_hash) ⇒ Object

Build an access token from access-token-hash or from token-string.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/omniauth-slack/slack.rb', line 13

def self.build_access_token(client_id, client_key, token_string_or_hash)
  client = OmniAuth::Slack::OAuth2::Client.new(
    client_id,
    client_key,
    OmniAuth::Strategies::Slack.default_options.client_options.to_h.map{|k,v| [k.to_sym, v]}.to_h
  )

  access_token = case
    when token_string_or_hash.is_a?(String)
      OmniAuth::Slack::OAuth2::AccessToken.new(client, token_string_or_hash)
    when token_string_or_hash.is_a?(Hash)
      OmniAuth::Slack::OAuth2::AccessToken.from_hash(client, token_string_or_hash)
  end
  
  access_token
end