class PhoneComClient::OauthApi

Attributes

api_client[RW]

Public Class Methods

new(api_client = ApiClient.default) click to toggle source
# File lib/phone_com_client/api/oauth_api.rb, line 19
def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Public Instance Methods

create_oauth_access_token(opts = {}) click to toggle source

To create an access token via the /oauth/access-token API, an API user may choose any one of the grant types it supports: Authorization Code Grant, Client Credential Grant, Password Credential Grant or Refresh Token Grant. To create an access token via the /oauth/access-token API, an API user may choose any one of the grant types it supports: Authorization Code Grant, Client Credential Grant, Password Credential Grant or Refresh Token Grant. For Authorization Code Grant, the input parameter 'code' is generated via the Create Authorization API. NOTE: The Create Access Token API now accepts requests in query string format as well as JSON body format. See OAuth for more details on how to obtain client id and client secret to create an access token at real time. @param [Hash] opts the optional parameters @option opts [CreateOauthParams] :data Oauth data @return [OauthAccessToken]

# File lib/phone_com_client/api/oauth_api.rb, line 27
def create_oauth_access_token(opts = {})
  data, _status_code, _headers = create_oauth_access_token_with_http_info(opts)
  data
end
create_oauth_access_token_with_http_info(opts = {}) click to toggle source

To create an access token via the /oauth/access-token API, an API user may choose any one of the grant types it supports: Authorization Code Grant, Client Credential Grant, Password Credential Grant or Refresh Token Grant. To create an access token via the /oauth/access-token API, an API user may choose any one of the grant types it supports: Authorization Code Grant, Client Credential Grant, Password Credential Grant or Refresh Token Grant. For Authorization Code Grant, the input parameter &#39;code&#39; is generated via the Create Authorization API. NOTE: The Create Access Token API now accepts requests in query string format as well as JSON body format. See OAuth for more details on how to obtain client id and client secret to create an access token at real time. @param [Hash] opts the optional parameters @option opts [CreateOauthParams] :data Oauth data @return [Array<(OauthAccessToken, Fixnum, Hash)>] OauthAccessToken data, response status code and response headers

# File lib/phone_com_client/api/oauth_api.rb, line 37
def create_oauth_access_token_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: OauthApi.create_oauth_access_token ...'
  end
  # resource path
  local_var_path = '/oauth/access-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/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = @api_client.object_to_http_body(opts[:'data'])
  auth_names = ['apiKey']
  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 => 'OauthAccessToken')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: OauthApi#create_oauth_access_token\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end
create_oauth_authorization(client_id, response_type, scope, redirect_uri, opts = {}) click to toggle source

Create Authorization Code or Access Token. Create Authorization Code or Access Token. The /oauth/authorization API supports Authorization Grant and Implicit Grant. In Authorization Grant, this API returns a code (response_type=code) for clients implemented in a browser using a scripting language such as JavaScript. Users may then use the code via the Create Access Token API to create an access token. The Implicit Grant is a simplified authorization code flow. In the implicit flow, instead of issuing the client an authorization code, the client is issued an access token (response_type=token) directly. See OAuth for more details on how to obtain client id and client secret to create authorization code access token at real time. @param client_id Client ID @param response_type &#39;token&#39; for Implicit Grant; &#39;code&#39; for Authorization Code Grant @param scope account-owner, extension-user and/or methods:ALL, separated by space (%20) @param redirect_uri The URL where the response data of this API is redirected to @param [Hash] opts the optional parameters @return [nil]

# File lib/phone_com_client/api/oauth_api.rb, line 80
def create_oauth_authorization(client_id, response_type, scope, redirect_uri, opts = {})
  create_oauth_authorization_with_http_info(client_id, response_type, scope, redirect_uri, opts)
  nil
end
create_oauth_authorization_with_http_info(client_id, response_type, scope, redirect_uri, opts = {}) click to toggle source

Create Authorization Code or Access Token. Create Authorization Code or Access Token. The /oauth/authorization API supports Authorization Grant and Implicit Grant. In Authorization Grant, this API returns a code (response_type&#x3D;code) for clients implemented in a browser using a scripting language such as JavaScript. Users may then use the code via the Create Access Token API to create an access token. The Implicit Grant is a simplified authorization code flow. In the implicit flow, instead of issuing the client an authorization code, the client is issued an access token (response_type&#x3D;token) directly. See OAuth for more details on how to obtain client id and client secret to create authorization code access token at real time. @param client_id Client ID @param response_type &#39;token&#39; for Implicit Grant; &#39;code&#39; for Authorization Code Grant @param scope account-owner, extension-user and/or methods:ALL, separated by space (%20) @param redirect_uri The URL where the response data of this API is redirected to @param [Hash] opts the optional parameters @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers

# File lib/phone_com_client/api/oauth_api.rb, line 93
def create_oauth_authorization_with_http_info(client_id, response_type, scope, redirect_uri, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: OauthApi.create_oauth_authorization ...'
  end
  # verify the required parameter 'client_id' is set
  if @api_client.config.client_side_validation && client_id.nil?
    fail ArgumentError, "Missing the required parameter 'client_id' when calling OauthApi.create_oauth_authorization"
  end
  # verify the required parameter 'response_type' is set
  if @api_client.config.client_side_validation && response_type.nil?
    fail ArgumentError, "Missing the required parameter 'response_type' when calling OauthApi.create_oauth_authorization"
  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 OauthApi.create_oauth_authorization"
  end
  # verify the required parameter 'redirect_uri' is set
  if @api_client.config.client_side_validation && redirect_uri.nil?
    fail ArgumentError, "Missing the required parameter 'redirect_uri' when calling OauthApi.create_oauth_authorization"
  end
  # resource path
  local_var_path = '/oauth/authorization'

  # query parameters
  query_params = {}
  query_params[:'client_id'] = client_id
  query_params[:'response_type'] = response_type
  query_params[:'scope'] = scope
  query_params[:'redirect_uri'] = redirect_uri

  # 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/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = ['apiKey']
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: OauthApi#create_oauth_authorization\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end
get_oauth_access_token(opts = {}) click to toggle source

Retrieve details of an access token, such as scope, expiration and extension ID. Retrieve details of an access token, such as scope, expiration and extension ID. Voip ID will be returned as well if scope contains account-owner scope. @param [Hash] opts the optional parameters @return [GetOauthAccessToken]

# File lib/phone_com_client/api/oauth_api.rb, line 151
def get_oauth_access_token(opts = {})
  data, _status_code, _headers = get_oauth_access_token_with_http_info(opts)
  data
end
get_oauth_access_token_with_http_info(opts = {}) click to toggle source

Retrieve details of an access token, such as scope, expiration and extension ID. Retrieve details of an access token, such as scope, expiration and extension ID. Voip ID will be returned as well if scope contains account-owner scope. @param [Hash] opts the optional parameters @return [Array<(GetOauthAccessToken, Fixnum, Hash)>] GetOauthAccessToken data, response status code and response headers

# File lib/phone_com_client/api/oauth_api.rb, line 160
def get_oauth_access_token_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: OauthApi.get_oauth_access_token ...'
  end
  # resource path
  local_var_path = '/oauth/access-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/json'])

  # form parameters
  form_params = {}

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