Class: RusticiSoftwareCloudV2::AuthenticationApi

Inherits:
Object
  • Object
show all
Defined in:
lib/rustici_software_cloud_v2/api/authentication_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ AuthenticationApi

Returns a new instance of AuthenticationApi.



19
20
21
# File 'lib/rustici_software_cloud_v2/api/authentication_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/rustici_software_cloud_v2/api/authentication_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#get_app_token(scope, opts = {}) ⇒ ApplicationToken

Authenticates for a oauth token Creates, signs and returns an OAuth2 token based on the provided permissions, if the credentials used to request the token have the permissions being requested. >Note: >The token is not stored and therefore can not be modified or deleted. The requested permissions are encoded in the token which is then signed. As long as the secret used to create it is not changed the token will be valid until it expires.

Parameters:

  • scope
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :expiration (Integer) — default: default to 300

Returns:



28
29
30
31
# File 'lib/rustici_software_cloud_v2/api/authentication_api.rb', line 28

def get_app_token(scope, opts = {})
  data, _status_code, _headers = get_app_token_with_http_info(scope, opts)
  data
end

#get_app_token_with_http_info(scope, opts = {}) ⇒ Array<(ApplicationToken, Fixnum, Hash)>

Authenticates for a oauth token Creates, signs and returns an OAuth2 token based on the provided permissions, if the credentials used to request the token have the permissions being requested. &gt;Note: &gt;The token is not stored and therefore can not be modified or deleted. The requested permissions are encoded in the token which is then signed. As long as the secret used to create it is not changed the token will be valid until it expires.

Parameters:

  • scope
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :expiration (Integer)

Returns:

  • (Array<(ApplicationToken, Fixnum, Hash)>)

    ApplicationToken data, response status code and response headers



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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
87
# File 'lib/rustici_software_cloud_v2/api/authentication_api.rb', line 39

def get_app_token_with_http_info(scope, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AuthenticationApi.get_app_token ...'
  end
  # verify the required parameter 'scope' is set
  if @api_client.config.client_side_validation && scope.nil?
    fail ArgumentError, "Missing the required parameter 'scope' when calling AuthenticationApi.get_app_token"
  end
  if @api_client.config.client_side_validation && !opts[:'expiration'].nil? && opts[:'expiration'] > 43200
    fail ArgumentError, 'invalid value for "opts[:"expiration"]" when calling AuthenticationApi.get_app_token, must be smaller than or equal to 43200.'
  end

  if @api_client.config.client_side_validation && !opts[:'expiration'].nil? && opts[:'expiration'] < 60
    fail ArgumentError, 'invalid value for "opts[:"expiration"]" when calling AuthenticationApi.get_app_token, must be greater than or equal to 60.'
  end

  # resource path
  local_var_path = '/oauth/authenticate/application/token'

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])

  # form parameters
  form_params = {}
  form_params['scope'] = scope
  form_params['expiration'] = opts[:'expiration'] if !opts[:'expiration'].nil?

  # http body (model)
  post_body = nil
  auth_names = ['APP_NORMAL']
  data, status_code, headers = @api_client.call_api(:POST, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'ApplicationToken')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: AuthenticationApi#get_app_token\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end