Class: ClerkHttpClient::SessionsApi
- Inherits:
-
Object
- Object
- ClerkHttpClient::SessionsApi
- Defined in:
- lib/clerk-http-client/api/sessions_api.rb
Instance Attribute Summary collapse
-
#api_client ⇒ Object
Returns the value of attribute api_client.
Instance Method Summary collapse
-
#create_session(opts = {}) ⇒ Session
Create a new active session Create a new active session for the provided user ID.
-
#create_session_token(session_id, opts = {}) ⇒ CreateSessionToken200Response
Create a session token Creates a session JSON Web Token (JWT) based on a session.
-
#create_session_token_from_template(session_id, template_name, opts = {}) ⇒ CreateSessionToken200Response
Create a session token from a jwt template Creates a JSON Web Token(JWT) based on a session and a JWT Template name defined for your instance.
-
#create_session_token_from_template_with_http_info(session_id, template_name, opts = {}) ⇒ Array<(CreateSessionToken200Response, Integer, Hash)>
Create a session token from a jwt template Creates a JSON Web Token(JWT) based on a session and a JWT Template name defined for your instance POST.
-
#create_session_token_with_http_info(session_id, opts = {}) ⇒ Array<(CreateSessionToken200Response, Integer, Hash)>
Create a session token Creates a session JSON Web Token (JWT) based on a session.
-
#create_session_with_http_info(opts = {}) ⇒ Array<(Session, Integer, Hash)>
Create a new active session Create a new active session for the provided user ID.
-
#get_session(session_id, opts = {}) ⇒ Session
Retrieve a session Retrieve the details of a session.
-
#get_session_list(opts = {}) ⇒ Array<Session>
List all sessions Returns a list of all sessions.
-
#get_session_list_with_http_info(opts = {}) ⇒ Array<(Array<Session>, Integer, Hash)>
List all sessions Returns a list of all sessions.
-
#get_session_with_http_info(session_id, opts = {}) ⇒ Array<(Session, Integer, Hash)>
Retrieve a session Retrieve the details of a session GET.
-
#initialize(api_client = ApiClient.default) ⇒ SessionsApi
constructor
A new instance of SessionsApi.
-
#revoke_session(session_id, opts = {}) ⇒ Session
Revoke a session Sets the status of a session as "revoked", which is an unauthenticated state.
-
#revoke_session_with_http_info(session_id, opts = {}) ⇒ Array<(Session, Integer, Hash)>
Revoke a session Sets the status of a session as "revoked", which is an unauthenticated state.
-
#verify_session(session_id, opts = {}) ⇒ Session
Verify a session Returns the session if it is authenticated, otherwise returns an error.
-
#verify_session_with_http_info(session_id, opts = {}) ⇒ Array<(Session, Integer, Hash)>
Verify a session Returns the session if it is authenticated, otherwise returns an error.
Constructor Details
#initialize(api_client = ApiClient.default) ⇒ SessionsApi
Returns a new instance of SessionsApi.
19 20 21 |
# File 'lib/clerk-http-client/api/sessions_api.rb', line 19 def initialize(api_client = ApiClient.default) @api_client = api_client end |
Instance Attribute Details
#api_client ⇒ Object
Returns the value of attribute api_client.
17 18 19 |
# File 'lib/clerk-http-client/api/sessions_api.rb', line 17 def api_client @api_client end |
Instance Method Details
#create_session(opts = {}) ⇒ Session
Create a new active session Create a new active session for the provided user ID. This operation is only available for Clerk Development instances.
28 29 30 31 |
# File 'lib/clerk-http-client/api/sessions_api.rb', line 28 def create_session(opts = {}) data, _status_code, _headers = create_session_with_http_info(opts) data end |
#create_session_token(session_id, opts = {}) ⇒ CreateSessionToken200Response
Create a session token Creates a session JSON Web Token (JWT) based on a session.
95 96 97 98 |
# File 'lib/clerk-http-client/api/sessions_api.rb', line 95 def create_session_token(session_id, opts = {}) data, _status_code, _headers = create_session_token_with_http_info(session_id, opts) data end |
#create_session_token_from_template(session_id, template_name, opts = {}) ⇒ CreateSessionToken200Response
Create a session token from a jwt template Creates a JSON Web Token(JWT) based on a session and a JWT Template name defined for your instance
168 169 170 171 |
# File 'lib/clerk-http-client/api/sessions_api.rb', line 168 def create_session_token_from_template(session_id, template_name, opts = {}) data, _status_code, _headers = create_session_token_from_template_with_http_info(session_id, template_name, opts) data end |
#create_session_token_from_template_with_http_info(session_id, template_name, opts = {}) ⇒ Array<(CreateSessionToken200Response, Integer, Hash)>
Create a session token from a jwt template Creates a JSON Web Token(JWT) based on a session and a JWT Template name defined for your instance POST
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
# File 'lib/clerk-http-client/api/sessions_api.rb', line 181 def create_session_token_from_template_with_http_info(session_id, template_name, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: SessionsApi.create_session_token_from_template ...' end # verify the required parameter 'session_id' is set if @api_client.config.client_side_validation && session_id.nil? fail ArgumentError, "Missing the required parameter 'session_id' when calling SessionsApi.create_session_token_from_template" end # verify the required parameter 'template_name' is set if @api_client.config.client_side_validation && template_name.nil? fail ArgumentError, "Missing the required parameter 'template_name' when calling SessionsApi.create_session_token_from_template" end # resource path local_var_path = '/sessions/{session_id}/tokens/{template_name}'.sub('{' + 'session_id' + '}', CGI.escape(session_id.to_s)).sub('{' + 'template_name' + '}', CGI.escape(template_name.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept'] # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['application/json']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'create_session_token_from_template_request']) # return_type return_type = opts[:debug_return_type] || 'CreateSessionToken200Response' # auth_names auth_names = opts[:debug_auth_names] || ['bearerAuth'] = opts.merge( :operation => :"SessionsApi.create_session_token_from_template", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: SessionsApi#create_session_token_from_template\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#create_session_token_with_http_info(session_id, opts = {}) ⇒ Array<(CreateSessionToken200Response, Integer, Hash)>
Create a session token Creates a session JSON Web Token (JWT) based on a session. POST
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/clerk-http-client/api/sessions_api.rb', line 107 def create_session_token_with_http_info(session_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: SessionsApi.create_session_token ...' end # verify the required parameter 'session_id' is set if @api_client.config.client_side_validation && session_id.nil? fail ArgumentError, "Missing the required parameter 'session_id' when calling SessionsApi.create_session_token" end # resource path local_var_path = '/sessions/{session_id}/tokens'.sub('{' + 'session_id' + '}', CGI.escape(session_id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept'] # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['application/json']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'create_session_token_request']) # return_type return_type = opts[:debug_return_type] || 'CreateSessionToken200Response' # auth_names auth_names = opts[:debug_auth_names] || ['bearerAuth'] = opts.merge( :operation => :"SessionsApi.create_session_token", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: SessionsApi#create_session_token\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#create_session_with_http_info(opts = {}) ⇒ Array<(Session, Integer, Hash)>
Create a new active session Create a new active session for the provided user ID. This operation is only available for Clerk Development instances. POST
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 |
# File 'lib/clerk-http-client/api/sessions_api.rb', line 39 def create_session_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: SessionsApi.create_session ...' end # resource path local_var_path = '/sessions' # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept'] # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['application/json']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'create_session_request']) # return_type return_type = opts[:debug_return_type] || 'Session' # auth_names auth_names = opts[:debug_auth_names] || ['bearerAuth'] = opts.merge( :operation => :"SessionsApi.create_session", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: SessionsApi#create_session\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#get_session(session_id, opts = {}) ⇒ Session
Retrieve a session Retrieve the details of a session
244 245 246 247 |
# File 'lib/clerk-http-client/api/sessions_api.rb', line 244 def get_session(session_id, opts = {}) data, _status_code, _headers = get_session_with_http_info(session_id, opts) data end |
#get_session_list(opts = {}) ⇒ Array<Session>
List all sessions Returns a list of all sessions. The sessions are returned sorted by creation date, with the newest sessions appearing first. **Deprecation Notice (2024-01-01):** All parameters were initially considered optional, however moving forward at least one of ‘client_id` or `user_id` parameters should be provided.
313 314 315 316 |
# File 'lib/clerk-http-client/api/sessions_api.rb', line 313 def get_session_list(opts = {}) data, _status_code, _headers = get_session_list_with_http_info(opts) data end |
#get_session_list_with_http_info(opts = {}) ⇒ Array<(Array<Session>, Integer, Hash)>
List all sessions Returns a list of all sessions. The sessions are returned sorted by creation date, with the newest sessions appearing first. **Deprecation Notice (2024-01-01):** All parameters were initially considered optional, however moving forward at least one of `client_id` or `user_id` parameters should be provided. GET array
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 |
# File 'lib/clerk-http-client/api/sessions_api.rb', line 328 def get_session_list_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: SessionsApi.get_session_list ...' end allowable_values = ["abandoned", "active", "ended", "expired", "removed", "replaced", "revoked"] if @api_client.config.client_side_validation && opts[:'status'] && !allowable_values.include?(opts[:'status']) fail ArgumentError, "invalid value for \"status\", must be one of #{allowable_values}" end if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 500 fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling SessionsApi.get_session_list, must be smaller than or equal to 500.' end if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1 fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling SessionsApi.get_session_list, must be greater than or equal to 1.' end if @api_client.config.client_side_validation && !opts[:'offset'].nil? && opts[:'offset'] < 0 fail ArgumentError, 'invalid value for "opts[:"offset"]" when calling SessionsApi.get_session_list, must be greater than or equal to 0.' end # resource path local_var_path = '/sessions' # query parameters query_params = opts[:query_params] || {} query_params[:'client_id'] = opts[:'client_id'] if !opts[:'client_id'].nil? query_params[:'user_id'] = opts[:'user_id'] if !opts[:'user_id'].nil? query_params[:'status'] = opts[:'status'] if !opts[:'status'].nil? query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil? query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil? # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept'] # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'Array<Session>' # auth_names auth_names = opts[:debug_auth_names] || ['bearerAuth'] = opts.merge( :operation => :"SessionsApi.get_session_list", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: SessionsApi#get_session_list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#get_session_with_http_info(session_id, opts = {}) ⇒ Array<(Session, Integer, Hash)>
Retrieve a session Retrieve the details of a session GET
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 |
# File 'lib/clerk-http-client/api/sessions_api.rb', line 255 def get_session_with_http_info(session_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: SessionsApi.get_session ...' end # verify the required parameter 'session_id' is set if @api_client.config.client_side_validation && session_id.nil? fail ArgumentError, "Missing the required parameter 'session_id' when calling SessionsApi.get_session" end # resource path local_var_path = '/sessions/{session_id}'.sub('{' + 'session_id' + '}', CGI.escape(session_id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept'] # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'Session' # auth_names auth_names = opts[:debug_auth_names] || ['bearerAuth'] = opts.merge( :operation => :"SessionsApi.get_session", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: SessionsApi#get_session\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#revoke_session(session_id, opts = {}) ⇒ Session
Revoke a session Sets the status of a session as "revoked", which is an unauthenticated state. In multi-session mode, a revoked session will still be returned along with its client object, however the user will need to sign in again.
399 400 401 402 |
# File 'lib/clerk-http-client/api/sessions_api.rb', line 399 def revoke_session(session_id, opts = {}) data, _status_code, _headers = revoke_session_with_http_info(session_id, opts) data end |
#revoke_session_with_http_info(session_id, opts = {}) ⇒ Array<(Session, Integer, Hash)>
Revoke a session Sets the status of a session as "revoked", which is an unauthenticated state. In multi-session mode, a revoked session will still be returned along with its client object, however the user will need to sign in again. POST
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 |
# File 'lib/clerk-http-client/api/sessions_api.rb', line 410 def revoke_session_with_http_info(session_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: SessionsApi.revoke_session ...' end # verify the required parameter 'session_id' is set if @api_client.config.client_side_validation && session_id.nil? fail ArgumentError, "Missing the required parameter 'session_id' when calling SessionsApi.revoke_session" end # resource path local_var_path = '/sessions/{session_id}/revoke'.sub('{' + 'session_id' + '}', CGI.escape(session_id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept'] # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'Session' # auth_names auth_names = opts[:debug_auth_names] || ['bearerAuth'] = opts.merge( :operation => :"SessionsApi.revoke_session", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: SessionsApi#revoke_session\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#verify_session(session_id, opts = {}) ⇒ Session
Verify a session Returns the session if it is authenticated, otherwise returns an error. WARNING: This endpoint is deprecated and will be removed in future versions. We strongly recommend switching to networkless verification using short-lived session tokens, which is implemented transparently in all recent SDK versions (e.g. [NodeJS SDK](clerk.com/docs/backend-requests/handling/nodejs#clerk-express-require-auth)). For more details on how networkless verification works, refer to our [Session Tokens documentation](clerk.com/docs/backend-requests/resources/session-tokens).
465 466 467 468 |
# File 'lib/clerk-http-client/api/sessions_api.rb', line 465 def verify_session(session_id, opts = {}) data, _status_code, _headers = verify_session_with_http_info(session_id, opts) data end |
#verify_session_with_http_info(session_id, opts = {}) ⇒ Array<(Session, Integer, Hash)>
Verify a session Returns the session if it is authenticated, otherwise returns an error. WARNING: This endpoint is deprecated and will be removed in future versions. We strongly recommend switching to networkless verification using short-lived session tokens, which is implemented transparently in all recent SDK versions (e.g. [NodeJS SDK](clerk.com/docs/backend-requests/handling/nodejs#clerk-express-require-auth)). For more details on how networkless verification works, refer to our [Session Tokens documentation](clerk.com/docs/backend-requests/resources/session-tokens). POST
477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 |
# File 'lib/clerk-http-client/api/sessions_api.rb', line 477 def verify_session_with_http_info(session_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: SessionsApi.verify_session ...' end # verify the required parameter 'session_id' is set if @api_client.config.client_side_validation && session_id.nil? fail ArgumentError, "Missing the required parameter 'session_id' when calling SessionsApi.verify_session" end # resource path local_var_path = '/sessions/{session_id}/verify'.sub('{' + 'session_id' + '}', CGI.escape(session_id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept'] # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['application/json']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'verify_session_request']) # return_type return_type = opts[:debug_return_type] || 'Session' # auth_names auth_names = opts[:debug_auth_names] || ['bearerAuth'] = opts.merge( :operation => :"SessionsApi.verify_session", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: SessionsApi#verify_session\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |