Skip to content

Conversation

@gjtorikian
Copy link
Contributor

Description

Based on the WorkOS API documentation, this kwarg is missing.

Closes #337

Documentation

Does this require changes to the WorkOS Docs? E.g. the API Reference or code snippets need updates.

[ ] Yes

If yes, link a related docs PR and add a docs maintainer as a reviewer. Their approval is required.

@gjtorikian gjtorikian requested a review from a team as a code owner February 10, 2026 17:19
@gjtorikian gjtorikian requested review from marktran and removed request for a team February 10, 2026 17:19
@gjtorikian gjtorikian changed the title Add invitation_token parameter to authentication methods fix: add invitation_token parameter to authentication methods Feb 10, 2026
@greptile-apps
Copy link

greptile-apps bot commented Feb 10, 2026

Greptile Overview

Greptile Summary

This PR adds an optional invitation_token keyword argument to three User Management authentication entrypoints (authenticate_with_password, authenticate_with_code, authenticate_with_magic_auth) and forwards it to the /user_management/authenticate request body. Specs were added to assert the new parameter is included in the request payload when provided.

Key integration point is WorkOS::UserManagement building request bodies that are serialized by WorkOS::Client.post_request (JSON via body.to_json).

Confidence Score: 3/5

  • This PR is close to mergeable but has a couple of correctness issues in request body construction and the new specs.
  • The core API surface change is small, but the new parameter is currently serialized as JSON null when omitted (unlike other optional params in this client), and the new specs stub post_request with an argument shape that doesn’t match the method signature, so they may not actually assert what they intend.
  • lib/workos/user_management.rb; spec/lib/workos/user_management_spec.rb

Important Files Changed

Filename Overview
lib/workos/user_management.rb Adds optional invitation_token kwarg to password, code, and magic auth authentication methods and passes it through to the authenticate request body.
spec/lib/workos/user_management_spec.rb Adds specs asserting invitation_token is included in request body for three authentication methods; uses request stubbing rather than VCR.

Sequence Diagram

sequenceDiagram
  participant App as App (workos-ruby)
  participant UM as WorkOS::UserManagement
  participant Client as WorkOS::Client
  participant API as WorkOS API

  App->>UM: authenticate_with_password(..., invitation_token)
  UM->>Client: post_request(path:"/user_management/authenticate", body:{..., invitation_token})
  Client->>API: HTTPS POST /user_management/authenticate (JSON)
  API-->>Client: 2xx response (tokens + user)
  Client-->>UM: response
  UM-->>App: AuthenticationResponse

  App->>UM: authenticate_with_code(..., invitation_token)
  UM->>Client: post_request(... body includes invitation_token)
  Client->>API: HTTPS POST /user_management/authenticate
  API-->>Client: 2xx response
  Client-->>UM: response
  UM-->>App: AuthenticationResponse

  App->>UM: authenticate_with_magic_auth(..., invitation_token)
  UM->>Client: post_request(... body includes invitation_token)
  Client->>API: HTTPS POST /user_management/authenticate
  API-->>Client: 2xx response
  Client-->>UM: response
  UM-->>App: AuthenticationResponse
Loading

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@greptile-apps
Copy link

greptile-apps bot commented Feb 10, 2026

Additional Comments (1)

lib/workos/user_management.rb
Nil field serialized as null

These methods always include invitation_token in the request body, even when it’s nil (see lib/workos/user_management.rb:327). Since post_request does body.to_json, that key will be sent as JSON null, which differs from other request bodies in this file that use .compact to omit optional fields and can break API validation if the parameter must be omitted when unused. Consider compacting the body (or conditionally adding the key) for authenticate_with_password, authenticate_with_code, and authenticate_with_magic_auth.

@gjtorikian gjtorikian merged commit d24e3dc into main Feb 10, 2026
6 of 7 checks passed
@gjtorikian gjtorikian deleted the add-invite-token branch February 10, 2026 18:51
gjtorikian added a commit that referenced this pull request Feb 10, 2026
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
gjtorikian added a commit that referenced this pull request Feb 10, 2026
* chore(main): release workos 6.1.0

* chore: add missing changelog entry for invitation_token fix (#438)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: workos-sdk-automation[bot] <255426317+workos-sdk-automation[bot]@users.noreply.github.com>
Co-authored-by: Garen J. Torikian <gjtorikian@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

Invitation token on authenticate_with_code

2 participants