Skip to content

Standalone Connect cannot finish because POST /authkit/oauth2/complete is missing #109

Description

@Amiyanshu-web

Summary

WorkOS Emulate does not implement this endpoint:

POST /authkit/oauth2/complete

This endpoint is the final step in a Standalone Connect login. Without it, an application cannot test the complete login flow against the emulator.

How the flow is supposed to work

  1. AuthKit starts an OAuth login.
  2. AuthKit sends the user to our application with a temporary external_auth_id.
  3. Our application signs the user in.
  4. Our backend sends the user and the external_auth_id to POST /authkit/oauth2/complete.
  5. WorkOS returns a redirect_uri.
  6. The browser follows that URL and finishes the OAuth login.

Step 4 does not work with WorkOS Emulate because the endpoint is missing.

What happens in the emulator

The emulator has no route for POST /authkit/oauth2/complete. The request therefore reaches its normal “route not found” handler and returns:

{"message":"Not Found","code":"not_found"}

with HTTP status 404.

This is confusing for a client because WorkOS can also return a 404 when an external_auth_id is invalid or expired. Our application therefore treats the emulator's “endpoint does not exist” response as “this login has expired” and asks the user to restart.

The endpoint is present in the WorkOS OpenAPI specification, but I could not find a matching implementation in the emulator's route files.

The generated SUPPORTED.md table reports partial coverage for Applications, but it does not name Standalone Connect or this missing endpoint directly.

Reproduction with v0.13.0

Start the emulator:

npx @workos/emulate@0.13.0 --port 4100

In another terminal, call the missing endpoint:

curl -s -w "\nHTTP %{http_code}\n" \
  -X POST http://localhost:4100/authkit/oauth2/complete \
  -H "Authorization: Bearer sk_test_default" \
  -H "Content-Type: application/json" \
  -d '{"external_auth_id":"ext_auth_01HXYZ123456789ABCDEFGHIJ","user":{"id":"user_12345","email":"marcelina.davis@example.com"}}'

Result:

{"message":"Not Found","code":"not_found"}
HTTP 404

As a control, GET /organizations returns 200 when called with the same API key. This confirms that the emulator is running and the key is valid.

Expected behavior

The real WorkOS endpoint accepts:

{
  "external_auth_id": "...",
  "user": {
    "id": "...",
    "email": "..."
  }
}

On success, it creates or updates the AuthKit user and returns:

{
  "redirect_uri": "..."
}

Important error cases are:

  • Reusing an external_auth_id that already completed → 400 external_auth_session_already_completed
  • Using an unknown or expired external_auth_id404

These cases are important because clients must decide whether to retry the request or restart the entire login.

Request

Please implement POST /authkit/oauth2/complete in the emulator.

The most complete implementation would also make the authorize flow create an external_auth_id, then require that ID when the completion endpoint is called.

Is this endpoint intentionally outside the emulator's current scope, or has it simply not been implemented yet?

Environment

@workos/emulate 0.13.0 · @workos-inc/node 8.13.0 · Node 22.22.2

If this is something you would be open to, I would be happy to submit a PR.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions