Class: WorkOS::UserManagement
- Inherits:
-
Object
- Object
- WorkOS::UserManagement
- Defined in:
- lib/workos/user_management.rb
Instance Method Summary collapse
-
#accept_invitation(id:, request_options: {}) ⇒ WorkOS::Invitation
Accept an invitation.
-
#authenticate_with_code(code:, code_verifier: nil, invitation_token: nil, ip_address: nil, device_id: nil, user_agent: nil, request_options: {}) ⇒ WorkOS::AuthenticateResponse
Authenticate with code.
-
#authenticate_with_code_pkce(code:, code_verifier:, client_id: nil, ip_address: nil, user_agent: nil, request_options: {}) ⇒ Object
H11 — Exchange a code for tokens with PKCE support (public client; no secret).
-
#authenticate_with_device_code(device_code:, ip_address: nil, device_id: nil, user_agent: nil, request_options: {}) ⇒ WorkOS::AuthenticateResponse
Authenticate with device code.
-
#authenticate_with_email_verification(code:, pending_authentication_token:, ip_address: nil, device_id: nil, user_agent: nil, request_options: {}) ⇒ WorkOS::AuthenticateResponse
Authenticate with email verification.
-
#authenticate_with_magic_auth(code:, email:, invitation_token: nil, ip_address: nil, device_id: nil, user_agent: nil, request_options: {}) ⇒ WorkOS::AuthenticateResponse
Authenticate with magic auth.
-
#authenticate_with_organization_selection(pending_authentication_token:, organization_id:, ip_address: nil, device_id: nil, user_agent: nil, request_options: {}) ⇒ WorkOS::AuthenticateResponse
Authenticate with organization selection.
-
#authenticate_with_password(email:, password:, invitation_token: nil, ip_address: nil, device_id: nil, user_agent: nil, request_options: {}) ⇒ WorkOS::AuthenticateResponse
Authenticate with password.
-
#authenticate_with_refresh_token(refresh_token:, organization_id: nil, ip_address: nil, device_id: nil, user_agent: nil, request_options: {}) ⇒ WorkOS::AuthenticateResponse
Authenticate with refresh token.
-
#authenticate_with_totp(code:, pending_authentication_token:, authentication_challenge_id:, ip_address: nil, device_id: nil, user_agent: nil, request_options: {}) ⇒ WorkOS::AuthenticateResponse
Authenticate with totp.
-
#authorize_device(client_id: nil, request_options: {}) ⇒ WorkOS::DeviceAuthorizationResponse
H12 — Initiate the OAuth 2.0 device authorization flow.
-
#confirm_email_change(id:, code:, request_options: {}) ⇒ WorkOS::EmailChangeConfirmation
Confirm email change.
-
#confirm_password_reset(token:, new_password:, request_options: {}) ⇒ WorkOS::ResetPasswordResponse
Reset the password.
-
#create_authenticate(client_id:, grant_type:, client_secret: nil, code: nil, code_verifier: nil, invitation_token: nil, ip_address: nil, device_id: nil, user_agent: nil, email: nil, password: nil, refresh_token: nil, organization_id: nil, pending_authentication_token: nil, authentication_challenge_id: nil, device_code: nil, request_options: {}) ⇒ WorkOS::AuthenticateResponse
Authenticate.
-
#create_cors_origin(origin:, request_options: {}) ⇒ WorkOS::CORSOriginResponse
Create a CORS origin.
-
#create_device(client_id:, request_options: {}) ⇒ WorkOS::DeviceAuthorizationResponse
Get device authorization URL.
-
#create_magic_auth(email:, invitation_token: nil, request_options: {}) ⇒ WorkOS::MagicAuth
Create a Magic Auth code.
-
#create_organization_membership(user_id:, organization_id:, role_slug: nil, role_slugs: nil, role: nil, request_options: {}) ⇒ WorkOS::OrganizationMembership
Create an organization membership.
-
#create_redirect_uri(uri:, request_options: {}) ⇒ WorkOS::RedirectUri
Create a redirect URI.
-
#create_user(email:, first_name: nil, last_name: nil, email_verified: nil, metadata: nil, external_id: nil, password: nil, password_hash: nil, password_hash_type: nil, request_options: {}) ⇒ WorkOS::User
Create a user.
-
#deactivate_organization_membership(id:, request_options: {}) ⇒ WorkOS::OrganizationMembership
Deactivate an organization membership.
-
#delete_organization_membership(id:, request_options: {}) ⇒ void
Delete an organization membership.
-
#delete_user(id:, request_options: {}) ⇒ void
Delete a user.
-
#delete_user_authorized_application(application_id:, user_id:, request_options: {}) ⇒ void
Delete an authorized application.
-
#find_invitation_by_token(token:, request_options: {}) ⇒ WorkOS::UserInvite
Find an invitation by token.
-
#get_authorization_url(redirect_uri:, client_id: nil, provider: nil, connection_id: nil, organization_id: nil, domain_hint: nil, login_hint: nil, state: nil, screen_hint: nil, code_challenge: nil, code_challenge_method: nil, prompt: nil) ⇒ Object
H09 — Build an AuthKit authorization URL (client-side, no HTTP call).
-
#get_authorization_url_with_pkce(redirect_uri:, client_id: nil, **opts) ⇒ Object
H10 — AuthKit authorization URL with auto-generated PKCE + state.
-
#get_email_verification(id:, request_options: {}) ⇒ WorkOS::EmailVerification
Get an email verification code.
-
#get_invitation(id:, request_options: {}) ⇒ WorkOS::UserInvite
Get an invitation.
-
#get_jwks(client_id:, request_options: {}) ⇒ WorkOS::JwksResponse
Get JWKS.
-
#get_jwks_url(client_id: nil) ⇒ Object
@oagen-ignore-start — non-spec helpers (hand-maintained) H13 — Build the JWKS URL for a given client_id (no HTTP call).
-
#get_logout_url(session_id:, return_to: nil) ⇒ String
Build the AuthKit logout redirect URL (client-side, no HTTP call).
-
#get_magic_auth(id:, request_options: {}) ⇒ WorkOS::MagicAuth
Get Magic Auth code details.
-
#get_organization_membership(id:, request_options: {}) ⇒ WorkOS::UserOrganizationMembership
Get an organization membership.
-
#get_password_reset(id:, request_options: {}) ⇒ WorkOS::PasswordReset
Get a password reset token.
-
#get_user(id:, request_options: {}) ⇒ WorkOS::User
Get a user.
-
#get_user_by_external_id(external_id:, request_options: {}) ⇒ WorkOS::User
Get a user by external ID.
-
#get_user_identities(id:, request_options: {}) ⇒ Array<WorkOS::UserIdentitiesGetItem>
Get user identities.
-
#initialize(client) ⇒ UserManagement
constructor
A new instance of UserManagement.
-
#list_invitations(before: nil, after: nil, limit: nil, order: "desc", organization_id: nil, email: nil, request_options: {}) ⇒ WorkOS::Types::ListStruct<WorkOS::UserInvite>
List invitations.
-
#list_organization_memberships(before: nil, after: nil, limit: nil, order: "desc", organization_id: nil, statuses: nil, user_id: nil, request_options: {}) ⇒ WorkOS::Types::ListStruct<WorkOS::UserOrganizationMembership>
List organization memberships.
-
#list_sessions(id:, before: nil, after: nil, limit: nil, order: "desc", request_options: {}) ⇒ WorkOS::Types::ListStruct<WorkOS::UserSessionsListItem>
List sessions.
-
#list_user_authorized_applications(user_id:, before: nil, after: nil, limit: nil, order: "desc", request_options: {}) ⇒ WorkOS::Types::ListStruct<WorkOS::AuthorizedConnectApplicationListData>
List authorized applications.
-
#list_users(before: nil, after: nil, limit: nil, order: "desc", organization: nil, organization_id: nil, email: nil, request_options: {}) ⇒ WorkOS::Types::ListStruct<WorkOS::User>
List users.
-
#reactivate_organization_membership(id:, request_options: {}) ⇒ WorkOS::UserOrganizationMembership
Reactivate an organization membership.
-
#resend_invitation(id:, locale: nil, request_options: {}) ⇒ WorkOS::UserInvite
Resend an invitation.
-
#reset_password(email:, request_options: {}) ⇒ WorkOS::PasswordReset
Create a password reset token.
-
#revoke_invitation(id:, request_options: {}) ⇒ WorkOS::Invitation
Revoke an invitation.
-
#revoke_session(session_id:, return_to: nil, request_options: {}) ⇒ void
Revoke Session.
-
#send_email_change(id:, new_email:, request_options: {}) ⇒ WorkOS::EmailChange
Send email change code.
-
#send_invitation(email:, organization_id: nil, role_slug: nil, expires_in_days: nil, inviter_user_id: nil, locale: nil, request_options: {}) ⇒ WorkOS::UserInvite
Send an invitation.
-
#send_verification_email(id:, request_options: {}) ⇒ WorkOS::SendVerificationEmailResponse
Send verification email.
-
#update_jwt_template(content:, request_options: {}) ⇒ WorkOS::JWTTemplateResponse
Update JWT template.
-
#update_organization_membership(id:, role_slug: nil, role_slugs: nil, role: nil, request_options: {}) ⇒ WorkOS::UserOrganizationMembership
Update an organization membership.
-
#update_user(id:, email: nil, first_name: nil, last_name: nil, email_verified: nil, metadata: nil, external_id: nil, locale: nil, password: nil, password_hash: nil, password_hash_type: nil, request_options: {}) ⇒ WorkOS::User
Update a user.
-
#verify_email(id:, code:, request_options: {}) ⇒ WorkOS::VerifyEmailResponse
Verify email.
Constructor Details
#initialize(client) ⇒ UserManagement
Returns a new instance of UserManagement.
9 10 11 |
# File 'lib/workos/user_management.rb', line 9 def initialize(client) @client = client end |
Instance Method Details
#accept_invitation(id:, request_options: {}) ⇒ WorkOS::Invitation
Accept an invitation
1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 |
# File 'lib/workos/user_management.rb', line 1076 def accept_invitation( id:, request_options: {} ) response = @client.request( method: :post, path: "/user_management/invitations/#{WorkOS::Util.encode_path(id)}/accept", auth: true, request_options: ) result = WorkOS::Invitation.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#authenticate_with_code(code:, code_verifier: nil, invitation_token: nil, ip_address: nil, device_id: nil, user_agent: nil, request_options: {}) ⇒ WorkOS::AuthenticateResponse
Authenticate with code.
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/workos/user_management.rb', line 148 def authenticate_with_code( code:, code_verifier: nil, invitation_token: nil, ip_address: nil, device_id: nil, user_agent: nil, request_options: {} ) body = { "grant_type" => "authorization_code", "client_id" => @client.client_id, "client_secret" => @client.api_key, "code" => code, "code_verifier" => code_verifier, "invitation_token" => invitation_token, "ip_address" => ip_address, "device_id" => device_id, "user_agent" => user_agent }.compact response = @client.request( method: :post, path: "/user_management/authenticate", auth: true, body: body, request_options: ) WorkOS::AuthenticateResponse.new(response.body) end |
#authenticate_with_code_pkce(code:, code_verifier:, client_id: nil, ip_address: nil, user_agent: nil, request_options: {}) ⇒ Object
H11 — Exchange a code for tokens with PKCE support (public client; no secret). NOTE: Unlike the other authenticate_with_* helpers, this does NOT delegate to create_authenticate because PKCE is a public-client flow that requires auth: false (no Bearer token / API key in the Authorization header).
1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 |
# File 'lib/workos/user_management.rb', line 1561 def authenticate_with_code_pkce(code:, code_verifier:, client_id: nil, ip_address: nil, user_agent: nil, request_options: {}) cid = client_id || @client.client_id raise ArgumentError, "client_id is required" if cid.nil? || cid.empty? body = { "grant_type" => "authorization_code", "client_id" => cid, "code" => code, "code_verifier" => code_verifier, "ip_address" => ip_address, "user_agent" => user_agent }.compact response = @client.request(method: :post, path: "/user_management/authenticate", auth: false, body: body, request_options: ) WorkOS::AuthenticateResponse.new(response.body) end |
#authenticate_with_device_code(device_code:, ip_address: nil, device_id: nil, user_agent: nil, request_options: {}) ⇒ WorkOS::AuthenticateResponse
Authenticate with device code.
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 |
# File 'lib/workos/user_management.rb', line 371 def authenticate_with_device_code( device_code:, ip_address: nil, device_id: nil, user_agent: nil, request_options: {} ) body = { "grant_type" => "urn:ietf:params:oauth:grant-type:device_code", "client_id" => @client.client_id, "device_code" => device_code, "ip_address" => ip_address, "device_id" => device_id, "user_agent" => user_agent }.compact response = @client.request( method: :post, path: "/user_management/authenticate", auth: true, body: body, request_options: ) WorkOS::AuthenticateResponse.new(response.body) end |
#authenticate_with_email_verification(code:, pending_authentication_token:, ip_address: nil, device_id: nil, user_agent: nil, request_options: {}) ⇒ WorkOS::AuthenticateResponse
Authenticate with email verification.
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 |
# File 'lib/workos/user_management.rb', line 261 def authenticate_with_email_verification( code:, pending_authentication_token:, ip_address: nil, device_id: nil, user_agent: nil, request_options: {} ) body = { "grant_type" => "urn:workos:oauth:grant-type:email-verification:code", "client_id" => @client.client_id, "client_secret" => @client.api_key, "code" => code, "pending_authentication_token" => pending_authentication_token, "ip_address" => ip_address, "device_id" => device_id, "user_agent" => user_agent }.compact response = @client.request( method: :post, path: "/user_management/authenticate", auth: true, body: body, request_options: ) WorkOS::AuthenticateResponse.new(response.body) end |
#authenticate_with_magic_auth(code:, email:, invitation_token: nil, ip_address: nil, device_id: nil, user_agent: nil, request_options: {}) ⇒ WorkOS::AuthenticateResponse
Authenticate with magic auth.
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
# File 'lib/workos/user_management.rb', line 223 def authenticate_with_magic_auth( code:, email:, invitation_token: nil, ip_address: nil, device_id: nil, user_agent: nil, request_options: {} ) body = { "grant_type" => "urn:workos:oauth:grant-type:magic-auth:code", "client_id" => @client.client_id, "client_secret" => @client.api_key, "code" => code, "email" => email, "invitation_token" => invitation_token, "ip_address" => ip_address, "device_id" => device_id, "user_agent" => user_agent }.compact response = @client.request( method: :post, path: "/user_management/authenticate", auth: true, body: body, request_options: ) WorkOS::AuthenticateResponse.new(response.body) end |
#authenticate_with_organization_selection(pending_authentication_token:, organization_id:, ip_address: nil, device_id: nil, user_agent: nil, request_options: {}) ⇒ WorkOS::AuthenticateResponse
Authenticate with organization selection.
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 |
# File 'lib/workos/user_management.rb', line 336 def authenticate_with_organization_selection( pending_authentication_token:, organization_id:, ip_address: nil, device_id: nil, user_agent: nil, request_options: {} ) body = { "grant_type" => "urn:workos:oauth:grant-type:organization-selection", "client_id" => @client.client_id, "client_secret" => @client.api_key, "pending_authentication_token" => pending_authentication_token, "organization_id" => organization_id, "ip_address" => ip_address, "device_id" => device_id, "user_agent" => user_agent }.compact response = @client.request( method: :post, path: "/user_management/authenticate", auth: true, body: body, request_options: ) WorkOS::AuthenticateResponse.new(response.body) end |
#authenticate_with_password(email:, password:, invitation_token: nil, ip_address: nil, device_id: nil, user_agent: nil, request_options: {}) ⇒ WorkOS::AuthenticateResponse
Authenticate with password.
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 |
# File 'lib/workos/user_management.rb', line 109 def authenticate_with_password( email:, password:, invitation_token: nil, ip_address: nil, device_id: nil, user_agent: nil, request_options: {} ) body = { "grant_type" => "password", "client_id" => @client.client_id, "client_secret" => @client.api_key, "email" => email, "password" => password, "invitation_token" => invitation_token, "ip_address" => ip_address, "device_id" => device_id, "user_agent" => user_agent }.compact response = @client.request( method: :post, path: "/user_management/authenticate", auth: true, body: body, request_options: ) WorkOS::AuthenticateResponse.new(response.body) end |
#authenticate_with_refresh_token(refresh_token:, organization_id: nil, ip_address: nil, device_id: nil, user_agent: nil, request_options: {}) ⇒ WorkOS::AuthenticateResponse
Authenticate with refresh token.
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 |
# File 'lib/workos/user_management.rb', line 186 def authenticate_with_refresh_token( refresh_token:, organization_id: nil, ip_address: nil, device_id: nil, user_agent: nil, request_options: {} ) body = { "grant_type" => "refresh_token", "client_id" => @client.client_id, "client_secret" => @client.api_key, "refresh_token" => refresh_token, "organization_id" => organization_id, "ip_address" => ip_address, "device_id" => device_id, "user_agent" => user_agent }.compact response = @client.request( method: :post, path: "/user_management/authenticate", auth: true, body: body, request_options: ) WorkOS::AuthenticateResponse.new(response.body) end |
#authenticate_with_totp(code:, pending_authentication_token:, authentication_challenge_id:, ip_address: nil, device_id: nil, user_agent: nil, request_options: {}) ⇒ WorkOS::AuthenticateResponse
Authenticate with totp.
298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 |
# File 'lib/workos/user_management.rb', line 298 def authenticate_with_totp( code:, pending_authentication_token:, authentication_challenge_id:, ip_address: nil, device_id: nil, user_agent: nil, request_options: {} ) body = { "grant_type" => "urn:workos:oauth:grant-type:mfa-totp", "client_id" => @client.client_id, "client_secret" => @client.api_key, "code" => code, "pending_authentication_token" => pending_authentication_token, "authentication_challenge_id" => authentication_challenge_id, "ip_address" => ip_address, "device_id" => device_id, "user_agent" => user_agent }.compact response = @client.request( method: :post, path: "/user_management/authenticate", auth: true, body: body, request_options: ) WorkOS::AuthenticateResponse.new(response.body) end |
#authorize_device(client_id: nil, request_options: {}) ⇒ WorkOS::DeviceAuthorizationResponse
H12 — Initiate the OAuth 2.0 device authorization flow.
1578 1579 1580 1581 1582 1583 1584 |
# File 'lib/workos/user_management.rb', line 1578 def (client_id: nil, request_options: {}) cid = client_id || @client.client_id raise ArgumentError, "client_id is required" if cid.nil? || cid.empty? body = {"client_id" => cid} response = @client.request(method: :post, path: "/oauth2/device_authorization", auth: false, body: body, request_options: ) WorkOS::DeviceAuthorizationResponse.new(response.body) end |
#confirm_email_change(id:, code:, request_options: {}) ⇒ WorkOS::EmailChangeConfirmation
Confirm email change
790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 |
# File 'lib/workos/user_management.rb', line 790 def confirm_email_change( id:, code:, request_options: {} ) body = { "code" => code }.compact response = @client.request( method: :post, path: "/user_management/users/#{WorkOS::Util.encode_path(id)}/email_change/confirm", auth: true, body: body, request_options: ) result = WorkOS::EmailChangeConfirmation.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#confirm_password_reset(token:, new_password:, request_options: {}) ⇒ WorkOS::ResetPasswordResponse
Reset the password
513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 |
# File 'lib/workos/user_management.rb', line 513 def confirm_password_reset( token:, new_password:, request_options: {} ) body = { "token" => token, "new_password" => new_password }.compact response = @client.request( method: :post, path: "/user_management/password_reset/confirm", auth: true, body: body, request_options: ) result = WorkOS::ResetPasswordResponse.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#create_authenticate(client_id:, grant_type:, client_secret: nil, code: nil, code_verifier: nil, invitation_token: nil, ip_address: nil, device_id: nil, user_agent: nil, email: nil, password: nil, refresh_token: nil, organization_id: nil, pending_authentication_token: nil, authentication_challenge_id: nil, device_code: nil, request_options: {}) ⇒ WorkOS::AuthenticateResponse
Authenticate
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 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/workos/user_management.rb', line 51 def create_authenticate( client_id:, grant_type:, client_secret: nil, code: nil, code_verifier: nil, invitation_token: nil, ip_address: nil, device_id: nil, user_agent: nil, email: nil, password: nil, refresh_token: nil, organization_id: nil, pending_authentication_token: nil, authentication_challenge_id: nil, device_code: nil, request_options: {} ) body = { "client_id" => client_id, "client_secret" => client_secret, "grant_type" => grant_type, "code" => code, "code_verifier" => code_verifier, "invitation_token" => invitation_token, "ip_address" => ip_address, "device_id" => device_id, "user_agent" => user_agent, "email" => email, "password" => password, "refresh_token" => refresh_token, "organization_id" => organization_id, "pending_authentication_token" => pending_authentication_token, "authentication_challenge_id" => authentication_challenge_id, "device_code" => device_code }.compact response = @client.request( method: :post, path: "/user_management/authenticate", auth: true, body: body, request_options: ) result = WorkOS::AuthenticateResponse.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#create_cors_origin(origin:, request_options: {}) ⇒ WorkOS::CORSOriginResponse
Create a CORS origin
447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 |
# File 'lib/workos/user_management.rb', line 447 def create_cors_origin( origin:, request_options: {} ) body = { "origin" => origin }.compact response = @client.request( method: :post, path: "/user_management/cors_origins", auth: true, body: body, request_options: ) result = WorkOS::CORSOriginResponse.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#create_device(client_id:, request_options: {}) ⇒ WorkOS::DeviceAuthorizationResponse
Get device authorization URL
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 |
# File 'lib/workos/user_management.rb', line 400 def create_device( client_id:, request_options: {} ) body = { "client_id" => client_id }.compact response = @client.request( method: :post, path: "/user_management/authorize/device", auth: true, body: body, request_options: ) result = WorkOS::DeviceAuthorizationResponse.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#create_magic_auth(email:, invitation_token: nil, request_options: {}) ⇒ WorkOS::MagicAuth
Create a Magic Auth code
1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 |
# File 'lib/workos/user_management.rb', line 1163 def create_magic_auth( email:, invitation_token: nil, request_options: {} ) body = { "email" => email, "invitation_token" => invitation_token }.compact response = @client.request( method: :post, path: "/user_management/magic_auth", auth: true, body: body, request_options: ) result = WorkOS::MagicAuth.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#create_organization_membership(user_id:, organization_id:, role_slug: nil, role_slugs: nil, role: nil, request_options: {}) ⇒ WorkOS::OrganizationMembership
Create an organization membership
1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 |
# File 'lib/workos/user_management.rb', line 1266 def create_organization_membership( user_id:, organization_id:, role_slug: nil, role_slugs: nil, role: nil, request_options: {} ) params = {}.compact if role case role[:type] when "single" params["role_slug"] = role[:role_slug] when "multiple" params["role_slugs"] = role[:role_slugs] end end body = { "user_id" => user_id, "organization_id" => organization_id, "role_slug" => role_slug, "role_slugs" => role_slugs }.compact response = @client.request( method: :post, path: "/user_management/organization_memberships", auth: true, params: params, body: body, request_options: ) result = WorkOS::OrganizationMembership.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#create_redirect_uri(uri:, request_options: {}) ⇒ WorkOS::RedirectUri
Create a redirect URI
1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 |
# File 'lib/workos/user_management.rb', line 1419 def create_redirect_uri( uri:, request_options: {} ) body = { "uri" => uri }.compact response = @client.request( method: :post, path: "/user_management/redirect_uris", auth: true, body: body, request_options: ) result = WorkOS::RedirectUri.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#create_user(email:, first_name: nil, last_name: nil, email_verified: nil, metadata: nil, external_id: nil, password: nil, password_hash: nil, password_hash_type: nil, request_options: {}) ⇒ WorkOS::User
Create a user
621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 |
# File 'lib/workos/user_management.rb', line 621 def create_user( email:, first_name: nil, last_name: nil, email_verified: nil, metadata: nil, external_id: nil, password: nil, password_hash: nil, password_hash_type: nil, request_options: {} ) params = {}.compact if password case password[:type] when "plaintext" params["password"] = password[:password] when "hashed" params["password_hash"] = password[:password_hash] params["password_hash_type"] = password[:password_hash_type] end end body = { "email" => email, "first_name" => first_name, "last_name" => last_name, "email_verified" => email_verified, "metadata" => , "external_id" => external_id, "password" => password, "password_hash" => password_hash, "password_hash_type" => password_hash_type }.compact response = @client.request( method: :post, path: "/user_management/users", auth: true, params: params, body: body, request_options: ) result = WorkOS::User.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#deactivate_organization_membership(id:, request_options: {}) ⇒ WorkOS::OrganizationMembership
Deactivate an organization membership
1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 |
# File 'lib/workos/user_management.rb', line 1381 def deactivate_organization_membership( id:, request_options: {} ) response = @client.request( method: :put, path: "/user_management/organization_memberships/#{WorkOS::Util.encode_path(id)}/deactivate", auth: true, request_options: ) result = WorkOS::OrganizationMembership.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#delete_organization_membership(id:, request_options: {}) ⇒ void
This method returns an undefined value.
Delete an organization membership
1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 |
# File 'lib/workos/user_management.rb', line 1364 def delete_organization_membership( id:, request_options: {} ) @client.request( method: :delete, path: "/user_management/organization_memberships/#{WorkOS::Util.encode_path(id)}", auth: true, request_options: ) nil end |
#delete_user(id:, request_options: {}) ⇒ void
This method returns an undefined value.
Delete a user
772 773 774 775 776 777 778 779 780 781 782 783 |
# File 'lib/workos/user_management.rb', line 772 def delete_user( id:, request_options: {} ) @client.request( method: :delete, path: "/user_management/users/#{WorkOS::Util.encode_path(id)}", auth: true, request_options: ) nil end |
#delete_user_authorized_application(application_id:, user_id:, request_options: {}) ⇒ void
This method returns an undefined value.
Delete an authorized application
1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 |
# File 'lib/workos/user_management.rb', line 1490 def ( application_id:, user_id:, request_options: {} ) @client.request( method: :delete, path: "/user_management/users/#{WorkOS::Util.encode_path(user_id)}/authorized_applications/#{WorkOS::Util.encode_path(application_id)}", auth: true, request_options: ) nil end |
#find_invitation_by_token(token:, request_options: {}) ⇒ WorkOS::UserInvite
Find an invitation by token
1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 |
# File 'lib/workos/user_management.rb', line 1038 def find_invitation_by_token( token:, request_options: {} ) response = @client.request( method: :get, path: "/user_management/invitations/by_token/#{WorkOS::Util.encode_path(token)}", auth: true, request_options: ) result = WorkOS::UserInvite.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#get_authorization_url(redirect_uri:, client_id: nil, provider: nil, connection_id: nil, organization_id: nil, domain_hint: nil, login_hint: nil, state: nil, screen_hint: nil, code_challenge: nil, code_challenge_method: nil, prompt: nil) ⇒ Object
H09 — Build an AuthKit authorization URL (client-side, no HTTP call). Overrides the generated get_authorization_url which hits the API.
1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 |
# File 'lib/workos/user_management.rb', line 1516 def (redirect_uri:, client_id: nil, provider: nil, connection_id: nil, organization_id: nil, domain_hint: nil, login_hint: nil, state: nil, screen_hint: nil, code_challenge: nil, code_challenge_method: nil, prompt: nil, **) cid = client_id || @client.client_id raise ArgumentError, "client_id is required (set on Client or pass explicitly)" if cid.nil? || cid.empty? raise ArgumentError, "provider, connection_id, or organization_id required" if provider.nil? && connection_id.nil? && organization_id.nil? params = { "client_id" => cid, "redirect_uri" => redirect_uri, "response_type" => "code", "provider" => provider, "connection_id" => connection_id, "organization_id" => organization_id, "domain_hint" => domain_hint, "login_hint" => login_hint, "state" => state, "screen_hint" => screen_hint, "code_challenge" => code_challenge, "code_challenge_method" => code_challenge_method, "prompt" => prompt }.compact build_url("/user_management/authorize", params) end |
#get_authorization_url_with_pkce(redirect_uri:, client_id: nil, **opts) ⇒ Object
H10 — AuthKit authorization URL with auto-generated PKCE + state. Returns [url, code_verifier, state].
1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 |
# File 'lib/workos/user_management.rb', line 1543 def (redirect_uri:, client_id: nil, **opts) pair = WorkOS::PKCE.generate_pair state = opts.delete(:state) || WorkOS::PKCE.generate_code_verifier url = ( redirect_uri: redirect_uri, client_id: client_id, state: state, code_challenge: pair[:code_challenge], code_challenge_method: "S256", **opts ) [url, pair[:code_verifier], state] end |
#get_email_verification(id:, request_options: {}) ⇒ WorkOS::EmailVerification
Get an email verification code
470 471 472 473 474 475 476 477 478 479 480 481 482 483 |
# File 'lib/workos/user_management.rb', line 470 def get_email_verification( id:, request_options: {} ) response = @client.request( method: :get, path: "/user_management/email_verification/#{WorkOS::Util.encode_path(id)}", auth: true, request_options: ) result = WorkOS::EmailVerification.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#get_invitation(id:, request_options: {}) ⇒ WorkOS::UserInvite
Get an invitation
1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 |
# File 'lib/workos/user_management.rb', line 1057 def get_invitation( id:, request_options: {} ) response = @client.request( method: :get, path: "/user_management/invitations/#{WorkOS::Util.encode_path(id)}", auth: true, request_options: ) result = WorkOS::UserInvite.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#get_jwks(client_id:, request_options: {}) ⇒ WorkOS::JwksResponse
Get JWKS
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/workos/user_management.rb', line 17 def get_jwks( client_id:, request_options: {} ) response = @client.request( method: :get, path: "/sso/jwks/#{WorkOS::Util.encode_path(client_id)}", auth: true, request_options: ) result = WorkOS::JwksResponse.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#get_jwks_url(client_id: nil) ⇒ Object
@oagen-ignore-start — non-spec helpers (hand-maintained) H13 — Build the JWKS URL for a given client_id (no HTTP call). Pair with #get_jwks (generated) to fetch the keyset.
1507 1508 1509 1510 1511 1512 |
# File 'lib/workos/user_management.rb', line 1507 def get_jwks_url(client_id: nil) cid = client_id || @client.client_id raise ArgumentError, "client_id is required" if cid.nil? || cid.empty? base = @client.base_url URI.join(base, "/sso/jwks/#{WorkOS::Util.encode_path(cid)}").to_s end |
#get_logout_url(session_id:, return_to: nil) ⇒ String
Build the AuthKit logout redirect URL (client-side, no HTTP call).
1594 1595 1596 1597 1598 |
# File 'lib/workos/user_management.rb', line 1594 def get_logout_url(session_id:, return_to: nil) params = {"session_id" => session_id} params["return_to"] = return_to if return_to build_url("/user_management/sessions/logout", params) end |
#get_magic_auth(id:, request_options: {}) ⇒ WorkOS::MagicAuth
Get Magic Auth code details
1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 |
# File 'lib/workos/user_management.rb', line 1188 def get_magic_auth( id:, request_options: {} ) response = @client.request( method: :get, path: "/user_management/magic_auth/#{WorkOS::Util.encode_path(id)}", auth: true, request_options: ) result = WorkOS::MagicAuth.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#get_organization_membership(id:, request_options: {}) ⇒ WorkOS::UserOrganizationMembership
Get an organization membership
1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 |
# File 'lib/workos/user_management.rb', line 1306 def get_organization_membership( id:, request_options: {} ) response = @client.request( method: :get, path: "/user_management/organization_memberships/#{WorkOS::Util.encode_path(id)}", auth: true, request_options: ) result = WorkOS::UserOrganizationMembership.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#get_password_reset(id:, request_options: {}) ⇒ WorkOS::PasswordReset
Get a password reset token
538 539 540 541 542 543 544 545 546 547 548 549 550 551 |
# File 'lib/workos/user_management.rb', line 538 def get_password_reset( id:, request_options: {} ) response = @client.request( method: :get, path: "/user_management/password_reset/#{WorkOS::Util.encode_path(id)}", auth: true, request_options: ) result = WorkOS::PasswordReset.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#get_user(id:, request_options: {}) ⇒ WorkOS::User
Get a user
690 691 692 693 694 695 696 697 698 699 700 701 702 703 |
# File 'lib/workos/user_management.rb', line 690 def get_user( id:, request_options: {} ) response = @client.request( method: :get, path: "/user_management/users/#{WorkOS::Util.encode_path(id)}", auth: true, request_options: ) result = WorkOS::User.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#get_user_by_external_id(external_id:, request_options: {}) ⇒ WorkOS::User
Get a user by external ID
671 672 673 674 675 676 677 678 679 680 681 682 683 684 |
# File 'lib/workos/user_management.rb', line 671 def get_user_by_external_id( external_id:, request_options: {} ) response = @client.request( method: :get, path: "/user_management/users/external_id/#{WorkOS::Util.encode_path(external_id)}", auth: true, request_options: ) result = WorkOS::User.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#get_user_identities(id:, request_options: {}) ⇒ Array<WorkOS::UserIdentitiesGetItem>
Get user identities
883 884 885 886 887 888 889 890 891 892 893 894 895 |
# File 'lib/workos/user_management.rb', line 883 def get_user_identities( id:, request_options: {} ) response = @client.request( method: :get, path: "/user_management/users/#{WorkOS::Util.encode_path(id)}/identities", auth: true, request_options: ) parsed = JSON.parse(response.body) (parsed || []).map { |item| WorkOS::UserIdentitiesGetItem.new(item) } end |
#list_invitations(before: nil, after: nil, limit: nil, order: "desc", organization_id: nil, email: nil, request_options: {}) ⇒ WorkOS::Types::ListStruct<WorkOS::UserInvite>
List invitations
953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 |
# File 'lib/workos/user_management.rb', line 953 def list_invitations( before: nil, after: nil, limit: nil, order: "desc", organization_id: nil, email: nil, request_options: {} ) params = { "before" => before, "after" => after, "limit" => limit, "order" => order, "organization_id" => organization_id, "email" => email }.compact response = @client.request( method: :get, path: "/user_management/invitations", auth: true, params: params, request_options: ) fetch_next = ->(cursor) { list_invitations( before: before, after: cursor, limit: limit, order: order, organization_id: organization_id, email: email, request_options: ) } WorkOS::Types::ListStruct.from_response( response, model: WorkOS::UserInvite, filters: {before: before, limit: limit, order: order, organization_id: organization_id, email: email}, fetch_next: fetch_next ) end |
#list_organization_memberships(before: nil, after: nil, limit: nil, order: "desc", organization_id: nil, statuses: nil, user_id: nil, request_options: {}) ⇒ WorkOS::Types::ListStruct<WorkOS::UserOrganizationMembership>
List organization memberships
1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 |
# File 'lib/workos/user_management.rb', line 1213 def list_organization_memberships( before: nil, after: nil, limit: nil, order: "desc", organization_id: nil, statuses: nil, user_id: nil, request_options: {} ) params = { "before" => before, "after" => after, "limit" => limit, "order" => order, "organization_id" => organization_id, "statuses" => statuses, "user_id" => user_id }.compact response = @client.request( method: :get, path: "/user_management/organization_memberships", auth: true, params: params, request_options: ) fetch_next = ->(cursor) { list_organization_memberships( before: before, after: cursor, limit: limit, order: order, organization_id: organization_id, statuses: statuses, user_id: user_id, request_options: ) } WorkOS::Types::ListStruct.from_response( response, model: WorkOS::UserOrganizationMembership, filters: {before: before, limit: limit, order: order, organization_id: organization_id, statuses: statuses, user_id: user_id}, fetch_next: fetch_next ) end |
#list_sessions(id:, before: nil, after: nil, limit: nil, order: "desc", request_options: {}) ⇒ WorkOS::Types::ListStruct<WorkOS::UserSessionsListItem>
List sessions
905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 |
# File 'lib/workos/user_management.rb', line 905 def list_sessions( id:, before: nil, after: nil, limit: nil, order: "desc", request_options: {} ) params = { "before" => before, "after" => after, "limit" => limit, "order" => order }.compact response = @client.request( method: :get, path: "/user_management/users/#{WorkOS::Util.encode_path(id)}/sessions", auth: true, params: params, request_options: ) fetch_next = ->(cursor) { list_sessions( id: id, before: before, after: cursor, limit: limit, order: order, request_options: ) } WorkOS::Types::ListStruct.from_response( response, model: WorkOS::UserSessionsListItem, filters: {id: id, before: before, limit: limit, order: order}, fetch_next: fetch_next ) end |
#list_user_authorized_applications(user_id:, before: nil, after: nil, limit: nil, order: "desc", request_options: {}) ⇒ WorkOS::Types::ListStruct<WorkOS::AuthorizedConnectApplicationListData>
List authorized applications
1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 |
# File 'lib/workos/user_management.rb', line 1446 def ( user_id:, before: nil, after: nil, limit: nil, order: "desc", request_options: {} ) params = { "before" => before, "after" => after, "limit" => limit, "order" => order }.compact response = @client.request( method: :get, path: "/user_management/users/#{WorkOS::Util.encode_path(user_id)}/authorized_applications", auth: true, params: params, request_options: ) fetch_next = ->(cursor) { ( user_id: user_id, before: before, after: cursor, limit: limit, order: order, request_options: ) } WorkOS::Types::ListStruct.from_response( response, model: WorkOS::AuthorizedConnectApplicationListData, filters: {user_id: user_id, before: before, limit: limit, order: order}, fetch_next: fetch_next ) end |
#list_users(before: nil, after: nil, limit: nil, order: "desc", organization: nil, organization_id: nil, email: nil, request_options: {}) ⇒ WorkOS::Types::ListStruct<WorkOS::User>
List users
563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 |
# File 'lib/workos/user_management.rb', line 563 def list_users( before: nil, after: nil, limit: nil, order: "desc", organization: nil, organization_id: nil, email: nil, request_options: {} ) params = { "before" => before, "after" => after, "limit" => limit, "order" => order, "organization" => organization, "organization_id" => organization_id, "email" => email }.compact response = @client.request( method: :get, path: "/user_management/users", auth: true, params: params, request_options: ) fetch_next = ->(cursor) { list_users( before: before, after: cursor, limit: limit, order: order, organization: organization, organization_id: organization_id, email: email, request_options: ) } WorkOS::Types::ListStruct.from_response( response, model: WorkOS::User, filters: {before: before, limit: limit, order: order, organization: organization, organization_id: organization_id, email: email}, fetch_next: fetch_next ) end |
#reactivate_organization_membership(id:, request_options: {}) ⇒ WorkOS::UserOrganizationMembership
Reactivate an organization membership
1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 |
# File 'lib/workos/user_management.rb', line 1400 def reactivate_organization_membership( id:, request_options: {} ) response = @client.request( method: :put, path: "/user_management/organization_memberships/#{WorkOS::Util.encode_path(id)}/reactivate", auth: true, request_options: ) result = WorkOS::UserOrganizationMembership.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#resend_invitation(id:, locale: nil, request_options: {}) ⇒ WorkOS::UserInvite
Resend an invitation
1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 |
# File 'lib/workos/user_management.rb', line 1096 def resend_invitation( id:, locale: nil, request_options: {} ) body = { "locale" => locale }.compact response = @client.request( method: :post, path: "/user_management/invitations/#{WorkOS::Util.encode_path(id)}/resend", auth: true, body: body, request_options: ) result = WorkOS::UserInvite.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#reset_password(email:, request_options: {}) ⇒ WorkOS::PasswordReset
Create a password reset token
489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 |
# File 'lib/workos/user_management.rb', line 489 def reset_password( email:, request_options: {} ) body = { "email" => email }.compact response = @client.request( method: :post, path: "/user_management/password_reset", auth: true, body: body, request_options: ) result = WorkOS::PasswordReset.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#revoke_invitation(id:, request_options: {}) ⇒ WorkOS::Invitation
Revoke an invitation
1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 |
# File 'lib/workos/user_management.rb', line 1120 def revoke_invitation( id:, request_options: {} ) response = @client.request( method: :post, path: "/user_management/invitations/#{WorkOS::Util.encode_path(id)}/revoke", auth: true, request_options: ) result = WorkOS::Invitation.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#revoke_session(session_id:, return_to: nil, request_options: {}) ⇒ void
This method returns an undefined value.
Revoke Session
424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 |
# File 'lib/workos/user_management.rb', line 424 def revoke_session( session_id:, return_to: nil, request_options: {} ) body = { "session_id" => session_id, "return_to" => return_to }.compact @client.request( method: :post, path: "/user_management/sessions/revoke", auth: true, body: body, request_options: ) nil end |
#send_email_change(id:, new_email:, request_options: {}) ⇒ WorkOS::EmailChange
Send email change code
815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 |
# File 'lib/workos/user_management.rb', line 815 def send_email_change( id:, new_email:, request_options: {} ) body = { "new_email" => new_email }.compact response = @client.request( method: :post, path: "/user_management/users/#{WorkOS::Util.encode_path(id)}/email_change/send", auth: true, body: body, request_options: ) result = WorkOS::EmailChange.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#send_invitation(email:, organization_id: nil, role_slug: nil, expires_in_days: nil, inviter_user_id: nil, locale: nil, request_options: {}) ⇒ WorkOS::UserInvite
Send an invitation
1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 |
# File 'lib/workos/user_management.rb', line 1005 def send_invitation( email:, organization_id: nil, role_slug: nil, expires_in_days: nil, inviter_user_id: nil, locale: nil, request_options: {} ) body = { "email" => email, "organization_id" => organization_id, "role_slug" => role_slug, "expires_in_days" => expires_in_days, "inviter_user_id" => inviter_user_id, "locale" => locale }.compact response = @client.request( method: :post, path: "/user_management/invitations", auth: true, body: body, request_options: ) result = WorkOS::UserInvite.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#send_verification_email(id:, request_options: {}) ⇒ WorkOS::SendVerificationEmailResponse
Send verification email
864 865 866 867 868 869 870 871 872 873 874 875 876 877 |
# File 'lib/workos/user_management.rb', line 864 def send_verification_email( id:, request_options: {} ) response = @client.request( method: :post, path: "/user_management/users/#{WorkOS::Util.encode_path(id)}/email_verification/send", auth: true, request_options: ) result = WorkOS::SendVerificationEmailResponse.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#update_jwt_template(content:, request_options: {}) ⇒ WorkOS::JWTTemplateResponse
Update JWT template
1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 |
# File 'lib/workos/user_management.rb', line 1139 def update_jwt_template( content:, request_options: {} ) body = { "content" => content }.compact response = @client.request( method: :put, path: "/user_management/jwt_template", auth: true, body: body, request_options: ) result = WorkOS::JWTTemplateResponse.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#update_organization_membership(id:, role_slug: nil, role_slugs: nil, role: nil, request_options: {}) ⇒ WorkOS::UserOrganizationMembership
Update an organization membership
1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 |
# File 'lib/workos/user_management.rb', line 1327 def update_organization_membership( id:, role_slug: nil, role_slugs: nil, role: nil, request_options: {} ) params = {}.compact if role case role[:type] when "single" params["role_slug"] = role[:role_slug] when "multiple" params["role_slugs"] = role[:role_slugs] end end body = { "role_slug" => role_slug, "role_slugs" => role_slugs }.compact response = @client.request( method: :put, path: "/user_management/organization_memberships/#{WorkOS::Util.encode_path(id)}", auth: true, params: params, body: body, request_options: ) result = WorkOS::UserOrganizationMembership.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#update_user(id:, email: nil, first_name: nil, last_name: nil, email_verified: nil, metadata: nil, external_id: nil, locale: nil, password: nil, password_hash: nil, password_hash_type: nil, request_options: {}) ⇒ WorkOS::User
Update a user
719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 |
# File 'lib/workos/user_management.rb', line 719 def update_user( id:, email: nil, first_name: nil, last_name: nil, email_verified: nil, metadata: nil, external_id: nil, locale: nil, password: nil, password_hash: nil, password_hash_type: nil, request_options: {} ) params = {}.compact if password case password[:type] when "plaintext" params["password"] = password[:password] when "hashed" params["password_hash"] = password[:password_hash] params["password_hash_type"] = password[:password_hash_type] end end body = { "email" => email, "first_name" => first_name, "last_name" => last_name, "email_verified" => email_verified, "metadata" => , "external_id" => external_id, "locale" => locale, "password" => password, "password_hash" => password_hash, "password_hash_type" => password_hash_type }.compact response = @client.request( method: :put, path: "/user_management/users/#{WorkOS::Util.encode_path(id)}", auth: true, params: params, body: body, request_options: ) result = WorkOS::User.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#verify_email(id:, code:, request_options: {}) ⇒ WorkOS::VerifyEmailResponse
Verify email
840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 |
# File 'lib/workos/user_management.rb', line 840 def verify_email( id:, code:, request_options: {} ) body = { "code" => code }.compact response = @client.request( method: :post, path: "/user_management/users/#{WorkOS::Util.encode_path(id)}/email_verification/confirm", auth: true, body: body, request_options: ) result = WorkOS::VerifyEmailResponse.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |