kinde_sdk 1.6.6 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/kinde_sdk/auth_controller.rb +96 -13
  3. data/kinde_api/lib/kinde_api/api/frontend/billing_api.rb +148 -0
  4. data/kinde_api/lib/kinde_api/api/frontend/feature_flags_api.rb +85 -0
  5. data/kinde_api/lib/kinde_api/api/frontend/o_auth_api.rb +241 -0
  6. data/kinde_api/lib/kinde_api/api/frontend/permissions_api.rb +85 -0
  7. data/kinde_api/lib/kinde_api/api/frontend/properties_api.rb +85 -0
  8. data/kinde_api/lib/kinde_api/api/frontend/roles_api.rb +85 -0
  9. data/kinde_api/lib/kinde_api/api/frontend/self_serve_portal_api.rb +89 -0
  10. data/kinde_api/lib/kinde_api/models/frontend/error.rb +230 -0
  11. data/kinde_api/lib/kinde_api/models/frontend/error_response.rb +221 -0
  12. data/kinde_api/lib/kinde_api/models/frontend/get_entitlement_response.rb +228 -0
  13. data/kinde_api/lib/kinde_api/models/frontend/get_entitlement_response_data.rb +229 -0
  14. data/kinde_api/lib/kinde_api/models/frontend/get_entitlement_response_data_entitlement.rb +295 -0
  15. data/kinde_api/lib/kinde_api/models/frontend/get_entitlements_response.rb +228 -0
  16. data/kinde_api/lib/kinde_api/models/frontend/get_entitlements_response_data.rb +244 -0
  17. data/kinde_api/lib/kinde_api/models/frontend/get_entitlements_response_data_entitlements_inner.rb +294 -0
  18. data/kinde_api/lib/kinde_api/models/frontend/get_entitlements_response_data_plans_inner.rb +240 -0
  19. data/kinde_api/lib/kinde_api/models/frontend/get_entitlements_response_metadata.rb +230 -0
  20. data/kinde_api/lib/kinde_api/models/frontend/get_feature_flags_response.rb +219 -0
  21. data/kinde_api/lib/kinde_api/models/frontend/get_feature_flags_response_data.rb +222 -0
  22. data/kinde_api/lib/kinde_api/models/frontend/get_feature_flags_response_data_feature_flags_inner.rb +259 -0
  23. data/kinde_api/lib/kinde_api/models/frontend/get_feature_flags_response_data_feature_flags_inner_value.rb +108 -0
  24. data/kinde_api/lib/kinde_api/models/frontend/get_user_permissions_response.rb +228 -0
  25. data/kinde_api/lib/kinde_api/models/frontend/get_user_permissions_response_data.rb +232 -0
  26. data/kinde_api/lib/kinde_api/models/frontend/get_user_permissions_response_data_permissions_inner.rb +240 -0
  27. data/kinde_api/lib/kinde_api/models/frontend/get_user_permissions_response_metadata.rb +230 -0
  28. data/kinde_api/lib/kinde_api/models/frontend/get_user_properties_response.rb +228 -0
  29. data/kinde_api/lib/kinde_api/models/frontend/get_user_properties_response_data.rb +222 -0
  30. data/kinde_api/lib/kinde_api/models/frontend/get_user_properties_response_data_properties_inner.rb +249 -0
  31. data/kinde_api/lib/kinde_api/models/frontend/get_user_properties_response_data_properties_inner_value.rb +107 -0
  32. data/kinde_api/lib/kinde_api/models/frontend/get_user_properties_response_metadata.rb +230 -0
  33. data/kinde_api/lib/kinde_api/models/frontend/get_user_roles_response.rb +228 -0
  34. data/kinde_api/lib/kinde_api/models/frontend/get_user_roles_response_data.rb +232 -0
  35. data/kinde_api/lib/kinde_api/models/frontend/get_user_roles_response_data_roles_inner.rb +240 -0
  36. data/kinde_api/lib/kinde_api/models/frontend/get_user_roles_response_metadata.rb +230 -0
  37. data/kinde_api/lib/kinde_api/models/frontend/portal_link.rb +220 -0
  38. data/kinde_api/lib/kinde_api/models/frontend/token_error_response.rb +230 -0
  39. data/kinde_api/lib/kinde_api/models/frontend/token_introspect.rb +262 -0
  40. data/kinde_api/lib/kinde_api/models/frontend/user_profile_v2.rb +323 -0
  41. data/kinde_api/lib/kinde_api.rb +28 -0
  42. data/lib/kinde_sdk/client/entitlements.rb +86 -0
  43. data/lib/kinde_sdk/client/feature_flags.rb +246 -10
  44. data/lib/kinde_sdk/client/permissions.rb +197 -6
  45. data/lib/kinde_sdk/client/roles.rb +218 -0
  46. data/lib/kinde_sdk/client.rb +242 -3
  47. data/lib/kinde_sdk/configuration.rb +2 -0
  48. data/lib/kinde_sdk/errors.rb +7 -0
  49. data/lib/kinde_sdk/internal/frontend_client.rb +111 -0
  50. data/lib/kinde_sdk/version.rb +1 -1
  51. data/lib/kinde_sdk.rb +9 -2
  52. metadata +54 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bce81ebfe4a744f53f2cb742a30c286f26597490aef729901356a54c067c9a3e
4
- data.tar.gz: e90c8e6347ed3f5ddaf9fc3c1519d63c264f3faadc5e9f69fb51048a1cfcaf4a
3
+ metadata.gz: 535ff46d086ced73b9c96057f1cdf7bd582cede497aa3d299ff6cef98d7d3259
4
+ data.tar.gz: 8ae57192d2f173ef0a84902832aadb63a7b81ff8a4a4603da7061b30c4f58bde
5
5
  SHA512:
6
- metadata.gz: 75145d5084c21ae190183eaa2df156698427f204f0fd85654312761174cc5c5fe80be947af247721555922ab2f99a49996454eff03315c3b06b78e03ac9d88f7
7
- data.tar.gz: 25267d878c9e91ae639bc3b1112f37225a96ea5954052eb6b1b312e8440433aacf6948ef24769542911e74c741694756595bdc4c22dc55933a95df1ad361adfd
6
+ metadata.gz: 7abe77f02ae645e9841037d3c8fdc7a7edc28e3f7d9a1e625d7c687f751b4e16ea86a0af7e96629e7043542ce92434de4eb9868eeba4c4ca51743d0568f3ab39
7
+ data.tar.gz: f98f1dd0411cd3cff285e1c7a1475a749f6d5ba1c9aa75077c6e25ba0a171e173a2308792d5ceafd7b330cb7aee904957f2a4dbbdbbca178fe76a65b77aa4a7b
@@ -29,7 +29,9 @@ module KindeSdk
29
29
  session[:auth_nonce] = nonce
30
30
  session[:auth_state] = {
31
31
  requested_at: Time.current.to_i,
32
- redirect_url: auth_data[:url]
32
+ redirect_url: auth_data[:url],
33
+ # Only allow reauth-leniency when reauth_state was provided
34
+ supports_reauth: params[:reauth_state].present?
33
35
  }
34
36
 
35
37
  redirect_to auth_data[:url], allow_other_host: true
@@ -41,6 +43,11 @@ module KindeSdk
41
43
  # Validates the response, exchanges code for tokens, and sets up the session
42
44
  # @return [void] Redirects to root path on success
43
45
  def callback
46
+ # Handle reauth errors first
47
+ if handle_reauth_error
48
+ return
49
+ end
50
+
44
51
  tokens = fetch_and_validate_tokens
45
52
  return if performed?
46
53
 
@@ -125,14 +132,65 @@ module KindeSdk
125
132
 
126
133
  private
127
134
 
135
+ def handle_reauth_error
136
+ error_param = params[:error]
137
+ return false unless error_param.present?
138
+
139
+ if error_param.downcase == "login_link_expired"
140
+ handle_expired_login_link
141
+ else
142
+ Rails.logger.warn("OAuth error received: #{error_param}")
143
+ end
144
+
145
+ true
146
+ end
147
+
148
+ def handle_expired_login_link
149
+ reauth_state = params[:reauth_state]
150
+ return unless reauth_state.present?
151
+
152
+ begin
153
+ decoded_auth_state = Base64.decode64(reauth_state)
154
+ reauth_data = JSON.parse(decoded_auth_state)
155
+
156
+ if reauth_data.present?
157
+ redirect_to build_reauth_url(reauth_data), allow_other_host: true
158
+ end
159
+ rescue ArgumentError => e
160
+ handle_error("Invalid reauth state encoding", e)
161
+ rescue JSON::ParserError => e
162
+ handle_error("Invalid reauth state format", e)
163
+ end
164
+ end
165
+
166
+ def build_reauth_url(reauth_data)
167
+ auth_url = "#{request.base_url}#{KindeSdk::Engine.routes.url_helpers.auth_path}"
168
+ query_string = URI.encode_www_form(reauth_data)
169
+ "#{auth_url}?#{query_string}"
170
+ end
171
+
128
172
  # Fetches and validates tokens from the authorization code
129
173
  # @return [Hash] The validated tokens or nil if validation fails
130
174
  def fetch_and_validate_tokens
131
- tokens = KindeSdk.fetch_tokens(
132
- params[:code],
133
- code_verifier: KindeSdk.config.pkce_enabled ? session[:code_verifier] : nil,
134
- redirect_uri: KindeSdk.config.callback_url
135
- )
175
+ begin
176
+ tokens = KindeSdk.fetch_tokens(
177
+ params[:code],
178
+ code_verifier: KindeSdk.config.pkce_enabled ? session[:code_verifier] : nil,
179
+ redirect_uri: KindeSdk.config.callback_url
180
+ )
181
+ rescue StandardError => e
182
+ # Handle PKCE-related errors that might occur during token fetch
183
+ if e.message.include?("PKCE code verifier") || e.message.include?("invalid_grant")
184
+ # This could be a reauth scenario where session data was lost
185
+ # Redirect back to auth to start fresh
186
+ Rails.logger.warn("PKCE/token issue detected (#{e.message}), redirecting to re-authenticate")
187
+ redirect_to "#{request.base_url}#{KindeSdk::Engine.routes.url_helpers.auth_path}"
188
+ return nil
189
+ end
190
+
191
+ # Re-raise other errors
192
+ raise e
193
+ end
136
194
 
137
195
  if tokens[:error].present?
138
196
  redirect_with_error("Token exchange failed: #{tokens[:error]}")
@@ -144,10 +202,15 @@ module KindeSdk
144
202
  KindeSdk.validate_jwt_token(tokens)
145
203
 
146
204
  # Validate nonce in ID token to prevent replay attacks
147
- decoded_token = JWT.decode(tokens[:id_token], nil, false)[0]
148
- unless decoded_token['nonce'] == session[:auth_nonce]
149
- redirect_with_error("Invalid authentication nonce")
150
- return nil
205
+ # Skip nonce validation if no session nonce (could be reauth scenario)
206
+ if session[:auth_nonce].present?
207
+ decoded_token = JWT.decode(tokens[:id_token], nil, false)[0]
208
+ unless decoded_token['nonce'] == session[:auth_nonce]
209
+ redirect_with_error("Invalid authentication nonce")
210
+ return nil
211
+ end
212
+ else
213
+ Rails.logger.warn("Skipping nonce validation - no session nonce found (possible reauth scenario)")
151
214
  end
152
215
 
153
216
  tokens
@@ -169,17 +232,37 @@ module KindeSdk
169
232
  # Checks state existence, matches returned state with stored state, and validates expiration
170
233
  # @return [void]
171
234
  def validate_state
235
+
236
+ error_param = params[:error]
237
+ if error_param.present?
238
+ if error_param.downcase == "login_link_expired"
239
+ return
240
+ end
241
+ end
172
242
  # Check if nonce and state exist in session
173
243
  unless session[:auth_state]
244
+ # If no session state but we have a code, check if this could be a reauth scenario
245
+ # In reauth scenarios, the session might be lost but we still have a valid OAuth code
246
+ if params[:code].present?
247
+ # Skip validation for potential reauth scenarios where session state is lost
248
+ return
249
+ end
250
+
174
251
  redirect_with_error("Invalid authentication state")
175
252
  return
176
253
  end
177
-
178
- # Verify nonce returned matches stored nonce
254
+
255
+ # If this auth flow supports reauth, be more lenient with validation
256
+ if session[:auth_state]["supports_reauth"]
257
+ # Only skip when both code _and_ state are supplied
258
+ return if params[:code].present? && params[:state].present?
259
+ end
260
+
261
+ # Normal state validation for non-reauth flows
179
262
  returned_state = params[:state]
180
263
  stored_state = session[:auth_state]
181
264
  stored_url = stored_state["redirect_url"]
182
-
265
+
183
266
  # Extract the state from the stored redirect_url
184
267
  parsed_url = URI.parse(stored_url)
185
268
  query_params = CGI.parse(parsed_url.query || "")
@@ -0,0 +1,148 @@
1
+ =begin
2
+ #Kinde Account API
3
+
4
+ # Provides endpoints to operate on an authenticated user. ## Intro ## How to use 1. Get a user access token - this can be obtained when a user signs in via the methods you've setup in Kinde (e.g. Google, passwordless, etc). 2. Call one of the endpoints below using the user access token in the Authorization header as a Bearer token. Typically, you can use the `getToken` command in the relevant SDK.
5
+
6
+ The version of the OpenAPI document: 1
7
+ Contact: support@kinde.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.4.0
10
+
11
+ =end
12
+
13
+ require 'cgi'
14
+
15
+ module KindeApi::Frontend
16
+ class BillingApi
17
+ attr_accessor :api_client
18
+
19
+ def initialize(api_client = ApiClient.default)
20
+ @api_client = api_client
21
+ end
22
+ # Get entitlement
23
+ # Returns a single entitlement by the feature key
24
+ # @param key [String] The key of the feature
25
+ # @param [Hash] opts the optional parameters
26
+ # @return [GetEntitlementResponse]
27
+ def get_entitlement(key, opts = {})
28
+ data, _status_code, _headers = get_entitlement_with_http_info(key, opts)
29
+ data
30
+ end
31
+
32
+ # Get entitlement
33
+ # Returns a single entitlement by the feature key
34
+ # @param key [String] The key of the feature
35
+ # @param [Hash] opts the optional parameters
36
+ # @return [Array<(GetEntitlementResponse, Integer, Hash)>] GetEntitlementResponse data, response status code and response headers
37
+ def get_entitlement_with_http_info(key, opts = {})
38
+ if @api_client.config.debugging
39
+ @api_client.config.logger.debug 'Calling API: BillingApi.get_entitlement ...'
40
+ end
41
+ # verify the required parameter 'key' is set
42
+ if @api_client.config.client_side_validation && key.nil?
43
+ fail ArgumentError, "Missing the required parameter 'key' when calling BillingApi.get_entitlement"
44
+ end
45
+ # resource path
46
+ local_var_path = '/account_api/v1/entitlement'.sub('{' + 'key' + '}', CGI.escape(key.to_s))
47
+
48
+ # query parameters
49
+ query_params = opts[:query_params] || {}
50
+
51
+ # header parameters
52
+ header_params = opts[:header_params] || {}
53
+ # HTTP header 'Accept' (if needed)
54
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
55
+
56
+ # form parameters
57
+ form_params = opts[:form_params] || {}
58
+
59
+ # http body (model)
60
+ post_body = opts[:debug_body]
61
+
62
+ # return_type
63
+ return_type = opts[:debug_return_type] || 'GetEntitlementResponse'
64
+
65
+ # auth_names
66
+ auth_names = opts[:debug_auth_names] || ['kindeBearerAuth']
67
+
68
+ new_options = opts.merge(
69
+ :operation => :"BillingApi.get_entitlement",
70
+ :header_params => header_params,
71
+ :query_params => query_params,
72
+ :form_params => form_params,
73
+ :body => post_body,
74
+ :auth_names => auth_names,
75
+ :return_type => return_type
76
+ )
77
+
78
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
79
+ if @api_client.config.debugging
80
+ @api_client.config.logger.debug "API called: BillingApi#get_entitlement\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
81
+ end
82
+ return data, status_code, headers
83
+ end
84
+
85
+ # Get entitlements
86
+ # Returns all the entitlements a the user currently has access to
87
+ # @param [Hash] opts the optional parameters
88
+ # @option opts [Integer] :page_size Number of results per page. Defaults to 10 if parameter not sent.
89
+ # @option opts [String] :starting_after The ID of the entitlement to start after.
90
+ # @return [GetEntitlementsResponse]
91
+ def get_entitlements(opts = {})
92
+ data, _status_code, _headers = get_entitlements_with_http_info(opts)
93
+ data
94
+ end
95
+
96
+ # Get entitlements
97
+ # Returns all the entitlements a the user currently has access to
98
+ # @param [Hash] opts the optional parameters
99
+ # @option opts [Integer] :page_size Number of results per page. Defaults to 10 if parameter not sent.
100
+ # @option opts [String] :starting_after The ID of the entitlement to start after.
101
+ # @return [Array<(GetEntitlementsResponse, Integer, Hash)>] GetEntitlementsResponse data, response status code and response headers
102
+ def get_entitlements_with_http_info(opts = {})
103
+ if @api_client.config.debugging
104
+ @api_client.config.logger.debug 'Calling API: BillingApi.get_entitlements ...'
105
+ end
106
+ # resource path
107
+ local_var_path = '/account_api/v1/entitlements'
108
+
109
+ # query parameters
110
+ query_params = opts[:query_params] || {}
111
+ query_params[:'page_size'] = opts[:'page_size'] if !opts[:'page_size'].nil?
112
+ query_params[:'starting_after'] = opts[:'starting_after'] if !opts[:'starting_after'].nil?
113
+
114
+ # header parameters
115
+ header_params = opts[:header_params] || {}
116
+ # HTTP header 'Accept' (if needed)
117
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
118
+
119
+ # form parameters
120
+ form_params = opts[:form_params] || {}
121
+
122
+ # http body (model)
123
+ post_body = opts[:debug_body]
124
+
125
+ # return_type
126
+ return_type = opts[:debug_return_type] || 'GetEntitlementsResponse'
127
+
128
+ # auth_names
129
+ auth_names = opts[:debug_auth_names] || ['kindeBearerAuth']
130
+
131
+ new_options = opts.merge(
132
+ :operation => :"BillingApi.get_entitlements",
133
+ :header_params => header_params,
134
+ :query_params => query_params,
135
+ :form_params => form_params,
136
+ :body => post_body,
137
+ :auth_names => auth_names,
138
+ :return_type => return_type
139
+ )
140
+
141
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
142
+ if @api_client.config.debugging
143
+ @api_client.config.logger.debug "API called: BillingApi#get_entitlements\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
144
+ end
145
+ return data, status_code, headers
146
+ end
147
+ end
148
+ end
@@ -0,0 +1,85 @@
1
+ =begin
2
+ #Kinde Account API
3
+
4
+ # Provides endpoints to operate on an authenticated user. ## Intro ## How to use 1. Get a user access token - this can be obtained when a user signs in via the methods you've setup in Kinde (e.g. Google, passwordless, etc). 2. Call one of the endpoints below using the user access token in the Authorization header as a Bearer token. Typically, you can use the `getToken` command in the relevant SDK.
5
+
6
+ The version of the OpenAPI document: 1
7
+ Contact: support@kinde.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.4.0
10
+
11
+ =end
12
+
13
+ require 'cgi'
14
+
15
+ module KindeApi::Frontend
16
+ class FeatureFlagsApi
17
+ attr_accessor :api_client
18
+
19
+ def initialize(api_client = ApiClient.default)
20
+ @api_client = api_client
21
+ end
22
+ # Get feature flags
23
+ # Returns all the feature flags that affect the user
24
+ # @param [Hash] opts the optional parameters
25
+ # @option opts [Integer] :page_size Number of results per page. Defaults to 10 if parameter not sent.
26
+ # @option opts [String] :starting_after The ID of the flag to start after.
27
+ # @return [GetFeatureFlagsResponse]
28
+ def get_feature_flags(opts = {})
29
+ data, _status_code, _headers = get_feature_flags_with_http_info(opts)
30
+ data
31
+ end
32
+
33
+ # Get feature flags
34
+ # Returns all the feature flags that affect the user
35
+ # @param [Hash] opts the optional parameters
36
+ # @option opts [Integer] :page_size Number of results per page. Defaults to 10 if parameter not sent.
37
+ # @option opts [String] :starting_after The ID of the flag to start after.
38
+ # @return [Array<(GetFeatureFlagsResponse, Integer, Hash)>] GetFeatureFlagsResponse data, response status code and response headers
39
+ def get_feature_flags_with_http_info(opts = {})
40
+ if @api_client.config.debugging
41
+ @api_client.config.logger.debug 'Calling API: FeatureFlagsApi.get_feature_flags ...'
42
+ end
43
+ # resource path
44
+ local_var_path = '/account_api/v1/feature_flags'
45
+
46
+ # query parameters
47
+ query_params = opts[:query_params] || {}
48
+ query_params[:'page_size'] = opts[:'page_size'] if !opts[:'page_size'].nil?
49
+ query_params[:'starting_after'] = opts[:'starting_after'] if !opts[:'starting_after'].nil?
50
+
51
+ # header parameters
52
+ header_params = opts[:header_params] || {}
53
+ # HTTP header 'Accept' (if needed)
54
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
55
+
56
+ # form parameters
57
+ form_params = opts[:form_params] || {}
58
+
59
+ # http body (model)
60
+ post_body = opts[:debug_body]
61
+
62
+ # return_type
63
+ return_type = opts[:debug_return_type] || 'GetFeatureFlagsResponse'
64
+
65
+ # auth_names
66
+ auth_names = opts[:debug_auth_names] || ['kindeBearerAuth']
67
+
68
+ new_options = opts.merge(
69
+ :operation => :"FeatureFlagsApi.get_feature_flags",
70
+ :header_params => header_params,
71
+ :query_params => query_params,
72
+ :form_params => form_params,
73
+ :body => post_body,
74
+ :auth_names => auth_names,
75
+ :return_type => return_type
76
+ )
77
+
78
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
79
+ if @api_client.config.debugging
80
+ @api_client.config.logger.debug "API called: FeatureFlagsApi#get_feature_flags\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
81
+ end
82
+ return data, status_code, headers
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,241 @@
1
+ =begin
2
+ #Kinde Account API
3
+
4
+ # Provides endpoints to operate on an authenticated user. ## Intro ## How to use 1. Get a user access token - this can be obtained when a user signs in via the methods you've setup in Kinde (e.g. Google, passwordless, etc). 2. Call one of the endpoints below using the user access token in the Authorization header as a Bearer token. Typically, you can use the `getToken` command in the relevant SDK.
5
+
6
+ The version of the OpenAPI document: 1
7
+ Contact: support@kinde.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.4.0
10
+
11
+ =end
12
+
13
+ require 'cgi'
14
+
15
+ module KindeApi::Frontend
16
+ class OAuthApi
17
+ attr_accessor :api_client
18
+
19
+ def initialize(api_client = ApiClient.default)
20
+ @api_client = api_client
21
+ end
22
+ # Get user profile
23
+ # This endpoint returns a user's ID, names, profile picture URL and email of the currently logged in user.
24
+ # @param [Hash] opts the optional parameters
25
+ # @return [UserProfileV2]
26
+ def get_user_profile_v2(opts = {})
27
+ data, _status_code, _headers = get_user_profile_v2_with_http_info(opts)
28
+ data
29
+ end
30
+
31
+ # Get user profile
32
+ # This endpoint returns a user&#39;s ID, names, profile picture URL and email of the currently logged in user.
33
+ # @param [Hash] opts the optional parameters
34
+ # @return [Array<(UserProfileV2, Integer, Hash)>] UserProfileV2 data, response status code and response headers
35
+ def get_user_profile_v2_with_http_info(opts = {})
36
+ if @api_client.config.debugging
37
+ @api_client.config.logger.debug 'Calling API: OAuthApi.get_user_profile_v2 ...'
38
+ end
39
+ # resource path
40
+ local_var_path = '/oauth2/v2/user_profile'
41
+
42
+ # query parameters
43
+ query_params = opts[:query_params] || {}
44
+
45
+ # header parameters
46
+ header_params = opts[:header_params] || {}
47
+ # HTTP header 'Accept' (if needed)
48
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
49
+
50
+ # form parameters
51
+ form_params = opts[:form_params] || {}
52
+
53
+ # http body (model)
54
+ post_body = opts[:debug_body]
55
+
56
+ # return_type
57
+ return_type = opts[:debug_return_type] || 'UserProfileV2'
58
+
59
+ # auth_names
60
+ auth_names = opts[:debug_auth_names] || ['kindeBearerAuth']
61
+
62
+ new_options = opts.merge(
63
+ :operation => :"OAuthApi.get_user_profile_v2",
64
+ :header_params => header_params,
65
+ :query_params => query_params,
66
+ :form_params => form_params,
67
+ :body => post_body,
68
+ :auth_names => auth_names,
69
+ :return_type => return_type
70
+ )
71
+
72
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
73
+ if @api_client.config.debugging
74
+ @api_client.config.logger.debug "API called: OAuthApi#get_user_profile_v2\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
75
+ end
76
+ return data, status_code, headers
77
+ end
78
+
79
+ # Introspect
80
+ # Retrieve information about the provided token.
81
+ # @param token [String] The token to be introspected.
82
+ # @param [Hash] opts the optional parameters
83
+ # @option opts [String] :token_type_hint A hint about the token type being queried in the request.
84
+ # @return [TokenIntrospect]
85
+ def token_introspection(token, opts = {})
86
+ data, _status_code, _headers = token_introspection_with_http_info(token, opts)
87
+ data
88
+ end
89
+
90
+ # Introspect
91
+ # Retrieve information about the provided token.
92
+ # @param token [String] The token to be introspected.
93
+ # @param [Hash] opts the optional parameters
94
+ # @option opts [String] :token_type_hint A hint about the token type being queried in the request.
95
+ # @return [Array<(TokenIntrospect, Integer, Hash)>] TokenIntrospect data, response status code and response headers
96
+ def token_introspection_with_http_info(token, opts = {})
97
+ if @api_client.config.debugging
98
+ @api_client.config.logger.debug 'Calling API: OAuthApi.token_introspection ...'
99
+ end
100
+ # verify the required parameter 'token' is set
101
+ if @api_client.config.client_side_validation && token.nil?
102
+ fail ArgumentError, "Missing the required parameter 'token' when calling OAuthApi.token_introspection"
103
+ end
104
+ allowable_values = ["access_token", "refresh_token"]
105
+ if @api_client.config.client_side_validation && opts[:'token_type_hint'] && !allowable_values.include?(opts[:'token_type_hint'])
106
+ fail ArgumentError, "invalid value for \"token_type_hint\", must be one of #{allowable_values}"
107
+ end
108
+ # resource path
109
+ local_var_path = '/oauth2/introspect'
110
+
111
+ # query parameters
112
+ query_params = opts[:query_params] || {}
113
+
114
+ # header parameters
115
+ header_params = opts[:header_params] || {}
116
+ # HTTP header 'Accept' (if needed)
117
+ header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/json; charset=utf-8'])
118
+ # HTTP header 'Content-Type'
119
+ content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])
120
+ if !content_type.nil?
121
+ header_params['Content-Type'] = content_type
122
+ end
123
+
124
+ # form parameters
125
+ form_params = opts[:form_params] || {}
126
+ form_params['token'] = token
127
+ form_params['token_type_hint'] = opts[:'token_type_hint'] if !opts[:'token_type_hint'].nil?
128
+
129
+ # http body (model)
130
+ post_body = opts[:debug_body]
131
+
132
+ # return_type
133
+ return_type = opts[:debug_return_type] || 'TokenIntrospect'
134
+
135
+ # auth_names
136
+ auth_names = opts[:debug_auth_names] || ['kindeBearerAuth']
137
+
138
+ new_options = opts.merge(
139
+ :operation => :"OAuthApi.token_introspection",
140
+ :header_params => header_params,
141
+ :query_params => query_params,
142
+ :form_params => form_params,
143
+ :body => post_body,
144
+ :auth_names => auth_names,
145
+ :return_type => return_type
146
+ )
147
+
148
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
149
+ if @api_client.config.debugging
150
+ @api_client.config.logger.debug "API called: OAuthApi#token_introspection\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
151
+ end
152
+ return data, status_code, headers
153
+ end
154
+
155
+ # Revoke token
156
+ # Use this endpoint to invalidate an access or refresh token. The token will no longer be valid for use.
157
+ # @param client_id [String] The &#x60;client_id&#x60; of your application.
158
+ # @param token [String] The token to be revoked.
159
+ # @param [Hash] opts the optional parameters
160
+ # @option opts [String] :client_secret The &#x60;client_secret&#x60; of your application. Required for backend apps only.
161
+ # @option opts [String] :token_type_hint The type of token to be revoked.
162
+ # @return [nil]
163
+ def token_revocation(client_id, token, opts = {})
164
+ token_revocation_with_http_info(client_id, token, opts)
165
+ nil
166
+ end
167
+
168
+ # Revoke token
169
+ # Use this endpoint to invalidate an access or refresh token. The token will no longer be valid for use.
170
+ # @param client_id [String] The &#x60;client_id&#x60; of your application.
171
+ # @param token [String] The token to be revoked.
172
+ # @param [Hash] opts the optional parameters
173
+ # @option opts [String] :client_secret The &#x60;client_secret&#x60; of your application. Required for backend apps only.
174
+ # @option opts [String] :token_type_hint The type of token to be revoked.
175
+ # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
176
+ def token_revocation_with_http_info(client_id, token, opts = {})
177
+ if @api_client.config.debugging
178
+ @api_client.config.logger.debug 'Calling API: OAuthApi.token_revocation ...'
179
+ end
180
+ # verify the required parameter 'client_id' is set
181
+ if @api_client.config.client_side_validation && client_id.nil?
182
+ fail ArgumentError, "Missing the required parameter 'client_id' when calling OAuthApi.token_revocation"
183
+ end
184
+ # verify the required parameter 'token' is set
185
+ if @api_client.config.client_side_validation && token.nil?
186
+ fail ArgumentError, "Missing the required parameter 'token' when calling OAuthApi.token_revocation"
187
+ end
188
+ allowable_values = ["access_token", "refresh_token"]
189
+ if @api_client.config.client_side_validation && opts[:'token_type_hint'] && !allowable_values.include?(opts[:'token_type_hint'])
190
+ fail ArgumentError, "invalid value for \"token_type_hint\", must be one of #{allowable_values}"
191
+ end
192
+ # resource path
193
+ local_var_path = '/oauth2/revoke'
194
+
195
+ # query parameters
196
+ query_params = opts[:query_params] || {}
197
+
198
+ # header parameters
199
+ header_params = opts[:header_params] || {}
200
+ # HTTP header 'Accept' (if needed)
201
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
202
+ # HTTP header 'Content-Type'
203
+ content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])
204
+ if !content_type.nil?
205
+ header_params['Content-Type'] = content_type
206
+ end
207
+
208
+ # form parameters
209
+ form_params = opts[:form_params] || {}
210
+ form_params['client_id'] = client_id
211
+ form_params['token'] = token
212
+ form_params['client_secret'] = opts[:'client_secret'] if !opts[:'client_secret'].nil?
213
+ form_params['token_type_hint'] = opts[:'token_type_hint'] if !opts[:'token_type_hint'].nil?
214
+
215
+ # http body (model)
216
+ post_body = opts[:debug_body]
217
+
218
+ # return_type
219
+ return_type = opts[:debug_return_type]
220
+
221
+ # auth_names
222
+ auth_names = opts[:debug_auth_names] || ['kindeBearerAuth']
223
+
224
+ new_options = opts.merge(
225
+ :operation => :"OAuthApi.token_revocation",
226
+ :header_params => header_params,
227
+ :query_params => query_params,
228
+ :form_params => form_params,
229
+ :body => post_body,
230
+ :auth_names => auth_names,
231
+ :return_type => return_type
232
+ )
233
+
234
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
235
+ if @api_client.config.debugging
236
+ @api_client.config.logger.debug "API called: OAuthApi#token_revocation\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
237
+ end
238
+ return data, status_code, headers
239
+ end
240
+ end
241
+ end