Skip to content

Add workos.pipes.getAccessToken#1394

Merged
dandorman merged 1 commit intomainfrom
dandorman/pipes-access-token
Dec 4, 2025
Merged

Add workos.pipes.getAccessToken#1394
dandorman merged 1 commit intomainfrom
dandorman/pipes-access-token

Conversation

@dandorman
Copy link
Contributor

Description

This adds support for the Pipes get-access-token endpoint.

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.

@dandorman dandorman requested a review from a team as a code owner November 21, 2025 01:27
@dandorman dandorman requested a review from alisherry November 21, 2025 01:27
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Nov 21, 2025

Greptile Overview

Greptile Summary

Added support for the Pipes getAccessToken endpoint to retrieve access tokens for data integrations. The implementation follows established patterns in the codebase with proper TypeScript interfaces, serialization/deserialization, and comprehensive test coverage.

Key Changes

  • Created new Pipes class with getAccessToken method that calls /data-integrations/{provider}/token
  • Implemented discriminated union types for success/failure responses (active: true|false)
  • Added proper date parsing for token expiry with null handling
  • Included test fixtures for all scenarios: success with/without expiry, not installed, needs reauthorization
  • Integrated Pipes module into main WorkOS class

Security Assessment

No security issues found. The implementation correctly avoids logging sensitive fields like access_token.

Confidence Score: 5/5

  • This PR is safe to merge with no issues found
  • Clean implementation that follows existing codebase patterns, includes comprehensive test coverage for all scenarios (success, failure, edge cases), proper TypeScript typing with discriminated unions, correct serialization/deserialization, and no security concerns
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
src/pipes/pipes.ts 5/5 Added getAccessToken method that calls the data-integrations endpoint with proper serialization/deserialization
src/pipes/interfaces/get-access-token.interface.ts 5/5 Defined request/response interfaces with discriminated unions for success/failure cases
src/pipes/serializers/get-access-token.serializer.ts 5/5 Implemented bidirectional serialization with proper handling of active/inactive states
src/pipes/pipes.spec.ts 5/5 Comprehensive test coverage for success, failure, and error scenarios with proper fixtures
src/workos.ts 5/5 Integrated Pipes module into main WorkOS class following existing patterns

Sequence Diagram

sequenceDiagram
    participant Client
    participant WorkOS
    participant Pipes
    participant Serializer
    participant API as WorkOS API

    Client->>WorkOS: pipes.getAccessToken({provider, userId, organizationId})
    WorkOS->>Pipes: getAccessToken()
    Pipes->>Serializer: serializeGetAccessTokenOptions()
    Serializer-->>Pipes: {user_id, organization_id}
    Pipes->>API: POST /data-integrations/{provider}/token
    
    alt Success with token
        API-->>Pipes: {active: true, access_token: {...}}
        Pipes->>Serializer: deserializeGetAccessTokenResponse()
        Serializer->>Serializer: deserializeAccessToken()
        Serializer-->>Pipes: {active: true, accessToken: {...}}
        Pipes-->>Client: Success response with token
    else Not installed
        API-->>Pipes: {active: false, error: "not_installed"}
        Pipes->>Serializer: deserializeGetAccessTokenResponse()
        Serializer-->>Pipes: {active: false, error: "not_installed"}
        Pipes-->>Client: Failure response
    else Needs reauth
        API-->>Pipes: {active: false, error: "needs_reauthorization"}
        Pipes->>Serializer: deserializeGetAccessTokenResponse()
        Serializer-->>Pipes: {active: false, error: "needs_reauthorization"}
        Pipes-->>Client: Failure response
    end
Loading

Copy link
Contributor

@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.

11 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@dandorman dandorman force-pushed the dandorman/pipes-access-token branch from 875e0aa to d75776a Compare November 26, 2025 22:21
@dandorman dandorman self-assigned this Nov 26, 2025
@dandorman dandorman requested a review from a team November 26, 2025 22:22
@dandorman dandorman force-pushed the dandorman/pipes-access-token branch from d75776a to 84bbefa Compare December 3, 2025 23:51
@dandorman dandorman merged commit 71b98f2 into main Dec 4, 2025
7 checks passed
@dandorman dandorman deleted the dandorman/pipes-access-token branch December 4, 2025 00:24
@dandorman dandorman mentioned this pull request Dec 4, 2025
dandorman added a commit that referenced this pull request Dec 4, 2025
## Description

- includes #1394 

## Documentation

Does this require changes to the WorkOS Docs? E.g. the [API
Reference](https://workos.com/docs/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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants