Class: ThePlaidApi::OauthGrantType

Inherits:
Object
  • Object
show all
Defined in:
lib/the_plaid_api/models/oauth_grant_type.rb

Overview

The type of OAuth grant being requested: ‘client_credentials` allows exchanging a client id and client secret for a refresh and access token. `refresh_token` allows refreshing an access token using a refresh token. When using this grant type, only the `refresh_token` field is required (along with the `client_id` and `client_secret`). `urn:ietf:params:oauth:grant-type:token-exchange` allows exchanging a subject token for an OAuth token. When using this grant type, the `audience`, `subject_token` and `subject_token_type` fields are required. These grants are defined in their respective RFCs. `refresh_token` and `client_credentials` are defined in RFC 6749 and `urn:ietf:params:oauth:grant-type:token-exchange` is defined in RFC 8693.

Constant Summary collapse

OAUTH_GRANT_TYPE =
[
  # TODO: Write general description for REFRESH_TOKEN
  REFRESH_TOKEN = 'refresh_token'.freeze,

  # TODO: Write general description for
  # ENUM_URNIETFPARAMS_OAUTH_GRANTTYPETOKENEXCHANGE
  ENUM_URNIETFPARAMS_OAUTH_GRANTTYPETOKENEXCHANGE = 'urn:ietf:params:oauth:grant-type:token-exchange'.freeze,

  # TODO: Write general description for CLIENT_CREDENTIALS
  CLIENT_CREDENTIALS = 'client_credentials'.freeze
].freeze

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = REFRESH_TOKEN) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/the_plaid_api/models/oauth_grant_type.rb', line 37

def self.from_value(value, default_value = REFRESH_TOKEN)
  return default_value if value.nil?

  str = value.to_s.strip

  case str.downcase
  when 'refresh_token' then REFRESH_TOKEN
  when 'enum_urnietfparams_oauth_granttypetokenexchange' then ENUM_URNIETFPARAMS_OAUTH_GRANTTYPETOKENEXCHANGE
  when 'client_credentials' then CLIENT_CREDENTIALS
  else
    default_value
  end
end

.validate(value) ⇒ Object



31
32
33
34
35
# File 'lib/the_plaid_api/models/oauth_grant_type.rb', line 31

def self.validate(value)
  return false if value.nil?

  OAUTH_GRANT_TYPE.include?(value)
end