Class: SlackWebApi::OauthController

Inherits:
BaseController show all
Defined in:
lib/slack_web_api/controllers/oauth_controller.rb

Overview

OauthController

Constant Summary

Constants inherited from BaseController

BaseController::GLOBAL_ERRORS

Instance Attribute Summary

Attributes inherited from BaseController

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseController

#initialize, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters

Constructor Details

This class inherits a constructor from SlackWebApi::BaseController

Instance Method Details

#oauth_access(client_id: nil, client_secret: nil, code: nil, redirect_uri: nil, single_channel: nil) ⇒ ApiResponse

Exchanges a temporary OAuth verifier code for an access token. application. your application. OAuth callback. originally submitted URI (if one was sent). the user to add your app only to a single channel. Only valid with a [legacy workspace app](api.slack.com/legacy-workspace-apps).

Parameters:

  • client_id (String) (defaults to: nil)

    Optional parameter: Issued when you created your

  • client_secret (String) (defaults to: nil)

    Optional parameter: Issued when you created

  • code (String) (defaults to: nil)

    Optional parameter: The code param returned via the

  • redirect_uri (String) (defaults to: nil)

    Optional parameter: This must match the

  • single_channel (TrueClass | FalseClass) (defaults to: nil)

    Optional parameter: Request

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/slack_web_api/controllers/oauth_controller.rb', line 22

def oauth_access(client_id: nil,
                 client_secret: nil,
                 code: nil,
                 redirect_uri: nil,
                 single_channel: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/oauth.access',
                                 Server::DEFAULT)
               .header_param(new_parameter('application/x-www-form-urlencoded', key: 'Content-Type'))
               .query_param(new_parameter(client_id, key: 'client_id'))
               .query_param(new_parameter(client_secret, key: 'client_secret'))
               .query_param(new_parameter(code, key: 'code'))
               .query_param(new_parameter(redirect_uri, key: 'redirect_uri'))
               .query_param(new_parameter(single_channel, key: 'single_channel'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('slackAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(DefaultSuccessTemplate.method(:from_hash))
                .is_api_response(true)
                .local_error('default',
                             'Typical error response',
                             DefaultErrorTemplateException))
    .execute
end

#oauth_token(client_id: nil, client_secret: nil, code: nil, redirect_uri: nil, single_channel: nil) ⇒ ApiResponse

Exchanges a temporary OAuth verifier code for a workspace token. application. your application. OAuth callback. originally submitted URI (if one was sent). the user to add your app only to a single channel.

Parameters:

  • client_id (String) (defaults to: nil)

    Optional parameter: Issued when you created your

  • client_secret (String) (defaults to: nil)

    Optional parameter: Issued when you created

  • code (String) (defaults to: nil)

    Optional parameter: The code param returned via the

  • redirect_uri (String) (defaults to: nil)

    Optional parameter: This must match the

  • single_channel (TrueClass | FalseClass) (defaults to: nil)

    Optional parameter: Request

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/slack_web_api/controllers/oauth_controller.rb', line 61

def oauth_token(client_id: nil,
                client_secret: nil,
                code: nil,
                redirect_uri: nil,
                single_channel: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/oauth.token',
                                 Server::DEFAULT)
               .header_param(new_parameter('application/x-www-form-urlencoded', key: 'Content-Type'))
               .query_param(new_parameter(client_id, key: 'client_id'))
               .query_param(new_parameter(client_secret, key: 'client_secret'))
               .query_param(new_parameter(code, key: 'code'))
               .query_param(new_parameter(redirect_uri, key: 'redirect_uri'))
               .query_param(new_parameter(single_channel, key: 'single_channel'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('slackAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(DefaultSuccessTemplate.method(:from_hash))
                .is_api_response(true)
                .local_error('default',
                             'Typical error response',
                             DefaultErrorTemplateException))
    .execute
end