Class: ThePlaidApi::OauthTokenRequest

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

Overview

OAuth token grant request.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(grant_type:, client_id: SKIP, client_secret: SKIP, secret: SKIP, scope: SKIP, refresh_token: SKIP, resource: SKIP, audience: SKIP, subject_token: SKIP, subject_token_type: SKIP, additional_properties: nil) ⇒ OauthTokenRequest

Returns a new instance of OauthTokenRequest.



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'lib/the_plaid_api/models/oauth_token_request.rb', line 139

def initialize(grant_type:, client_id: SKIP, client_secret: SKIP,
               secret: SKIP, scope: SKIP, refresh_token: SKIP,
               resource: SKIP, audience: SKIP, subject_token: SKIP,
               subject_token_type: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @grant_type = grant_type
  @client_id = client_id unless client_id == SKIP
  @client_secret = client_secret unless client_secret == SKIP
  @secret = secret unless secret == SKIP
  @scope = scope unless scope == SKIP
  @refresh_token = refresh_token unless refresh_token == SKIP
  @resource = resource unless resource == SKIP
  @audience = audience unless audience == SKIP
  @subject_token = subject_token unless subject_token == SKIP
  @subject_token_type = subject_token_type unless subject_token_type == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#audienceString

Used when exchanging a token. The meaning depends on the ‘subject_token_type`:

  • For ‘urn:plaid:params:tokens:user`: Must be the same as the `client_id`.

  • For ‘urn:plaid:params:oauth:user-token`: The other `client_id` to

exchange tokens to.

  • For ‘urn:plaid:params:credit:multi-user`: a `client_id` or one of the

supported CRA partner URNs: ‘urn:plaid:params:cra-partner:experian`, `urn:plaid:params:cra-partner:fannie-mae`, or `urn:plaid:params:cra-partner:freddie-mac`.

Returns:

  • (String)


76
77
78
# File 'lib/the_plaid_api/models/oauth_token_request.rb', line 76

def audience
  @audience
end

#client_idString

Your Plaid API ‘client_id`. The `client_id` is required and may be provided either in the `PLAID-CLIENT-ID` header or as part of a request body.

Returns:

  • (String)


31
32
33
# File 'lib/the_plaid_api/models/oauth_token_request.rb', line 31

def client_id
  @client_id
end

#client_secretString

Your Plaid API ‘secret`. The `secret` is required and may be provided either in the `PLAID-SECRET` header or as part of a request body as either `secret` or `client_secret`.

Returns:

  • (String)


37
38
39
# File 'lib/the_plaid_api/models/oauth_token_request.rb', line 37

def client_secret
  @client_secret
end

#grant_typeOauthGrantType

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.

Returns:



25
26
27
# File 'lib/the_plaid_api/models/oauth_token_request.rb', line 25

def grant_type
  @grant_type
end

#refresh_tokenString

Refresh token for OAuth

Returns:

  • (String)


60
61
62
# File 'lib/the_plaid_api/models/oauth_token_request.rb', line 60

def refresh_token
  @refresh_token
end

#resourceString

URI of the target resource server

Returns:

  • (String)


64
65
66
# File 'lib/the_plaid_api/models/oauth_token_request.rb', line 64

def resource
  @resource
end

#scopeString

A JSON string containing a space-separated list of scopes associated with this token, in the format described in [datatracker.ietf.org/doc/html/rfc6749#section-3.3](https://datatr acker.ietf.org/doc/html/rfc6749#section-3.3). Currently accepted values are: ‘user:read` allows reading user data. `user:write` allows writing user data. `exchange` allows exchanging a token using the `urn:plaid:params:oauth:user-token` grant type. `mcp:dashboard` allows access to the MCP dashboard server.

Returns:

  • (String)


56
57
58
# File 'lib/the_plaid_api/models/oauth_token_request.rb', line 56

def scope
  @scope
end

#secretString

Your Plaid API ‘secret`. The `secret` is required and may be provided either in the `PLAID-SECRET` header or as part of a request body as either `secret` or `client_secret`.

Returns:

  • (String)


43
44
45
# File 'lib/the_plaid_api/models/oauth_token_request.rb', line 43

def secret
  @secret
end

#subject_tokenString

Token representing the subject. The ‘subject token` must be an OAuth refresh token issued from the `/oauth/token` endpoint. The meaning depends on the `subject_token_type`.

Returns:

  • (String)


82
83
84
# File 'lib/the_plaid_api/models/oauth_token_request.rb', line 82

def subject_token
  @subject_token
end

#subject_token_typeOauthSubjectTokenType

The type of the subject token. ‘urn:plaid:params:tokens:user` allows exchanging a Plaid-issued user token for an OAuth token. When using this token type, `audience` must be the same as the `client_id`. `subject_token` must be a Plaid-issued user token issued from the `/user/create` endpoint. `urn:plaid:params:oauth:user-token` allows exchanging a refresh token for an OAuth token to another `client_id`. The other `client_id` is provided in `audience`. `subject_token` must be an OAuth refresh token issued from the `/oauth/token` endpoint. `urn:plaid:params:credit:multi-user` allows exchanging a Plaid-issued user token for an OAuth token. When using this token type, `audience` may be a client id or a supported CRA partner URN. `audience` supports a comma-delimited list of clients. When multiple clients are specified in the `audience` a multi-party token is created which can be used by all parties in the audience in conjunction with their `client_id` and `client_secret`.



101
102
103
# File 'lib/the_plaid_api/models/oauth_token_request.rb', line 101

def subject_token_type
  @subject_token_type
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# File 'lib/the_plaid_api/models/oauth_token_request.rb', line 160

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  grant_type = hash.key?('grant_type') ? hash['grant_type'] : nil
  client_id = hash.key?('client_id') ? hash['client_id'] : SKIP
  client_secret = hash.key?('client_secret') ? hash['client_secret'] : SKIP
  secret = hash.key?('secret') ? hash['secret'] : SKIP
  scope = hash.key?('scope') ? hash['scope'] : SKIP
  refresh_token = hash.key?('refresh_token') ? hash['refresh_token'] : SKIP
  resource = hash.key?('resource') ? hash['resource'] : SKIP
  audience = hash.key?('audience') ? hash['audience'] : SKIP
  subject_token = hash.key?('subject_token') ? hash['subject_token'] : SKIP
  subject_token_type =
    hash.key?('subject_token_type') ? hash['subject_token_type'] : SKIP

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  OauthTokenRequest.new(grant_type: grant_type,
                        client_id: client_id,
                        client_secret: client_secret,
                        secret: secret,
                        scope: scope,
                        refresh_token: refresh_token,
                        resource: resource,
                        audience: audience,
                        subject_token: subject_token,
                        subject_token_type: subject_token_type,
                        additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/the_plaid_api/models/oauth_token_request.rb', line 104

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['grant_type'] = 'grant_type'
  @_hash['client_id'] = 'client_id'
  @_hash['client_secret'] = 'client_secret'
  @_hash['secret'] = 'secret'
  @_hash['scope'] = 'scope'
  @_hash['refresh_token'] = 'refresh_token'
  @_hash['resource'] = 'resource'
  @_hash['audience'] = 'audience'
  @_hash['subject_token'] = 'subject_token'
  @_hash['subject_token_type'] = 'subject_token_type'
  @_hash
end

.nullablesObject

An array for nullable fields



135
136
137
# File 'lib/the_plaid_api/models/oauth_token_request.rb', line 135

def self.nullables
  []
end

.optionalsObject

An array for optional fields



120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/the_plaid_api/models/oauth_token_request.rb', line 120

def self.optionals
  %w[
    client_id
    client_secret
    secret
    scope
    refresh_token
    resource
    audience
    subject_token
    subject_token_type
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



208
209
210
211
212
213
214
215
216
# File 'lib/the_plaid_api/models/oauth_token_request.rb', line 208

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} grant_type: #{@grant_type.inspect}, client_id: #{@client_id.inspect},"\
  " client_secret: #{@client_secret.inspect}, secret: #{@secret.inspect}, scope:"\
  " #{@scope.inspect}, refresh_token: #{@refresh_token.inspect}, resource:"\
  " #{@resource.inspect}, audience: #{@audience.inspect}, subject_token:"\
  " #{@subject_token.inspect}, subject_token_type: #{@subject_token_type.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



198
199
200
201
202
203
204
205
# File 'lib/the_plaid_api/models/oauth_token_request.rb', line 198

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} grant_type: #{@grant_type}, client_id: #{@client_id}, client_secret:"\
  " #{@client_secret}, secret: #{@secret}, scope: #{@scope}, refresh_token: #{@refresh_token},"\
  " resource: #{@resource}, audience: #{@audience}, subject_token: #{@subject_token},"\
  " subject_token_type: #{@subject_token_type}, additional_properties:"\
  " #{@additional_properties}>"
end