Skip to content

Declare the Location header on OAuth2 redirect responses in the OpenAPI spec #14155

Open
appwrite/sdk-generator
#1983

Description

@ChiragAgg5k

Summary

The OpenAPI 3 spec describes the two OAuth2 redirect endpoints as returning an HTML body with no destination. A 301 is a redirect, and the part a client needs is the Location header. This issue covers declaring the redirect properly in the spec, using only standard OpenAPI fields.

Affected operations (the only 3xx operations in the 2.3.x spec):

  • GET /account/sessions/oauth2/{provider} (createOAuth2Session)
  • GET /account/tokens/oauth2/{provider} (createOAuth2Token)

Current

"responses": {
  "301": {
    "description": "No content",
    "content": {
      "text/html": {
        "schema": {
          "type": "string",
          "format": "binary"
        }
      }
    }
  }
}

Proposed

"responses": {
  "301": {
    "description": "Redirect to the OAuth2 provider's sign-in page.",
    "headers": {
      "Location": {
        "description": "URL of the OAuth2 provider's authorization page.",
        "schema": {
          "type": "string",
          "format": "uri"
        }
      }
    }
  }
}
  • Drop content. The body of a redirect is not part of the API.
  • Add headers.Location (OpenAPI 3.0 Response Object headers).
  • Replace the "No content" description with one that says what the response does.

Where

src/Appwrite/SDK/Specification/Format/OpenAPI3.php:

  • Lines ~504-512 add the binary content because the route's content type is HTML.
  • Lines ~547-552 set the description to "No content" for 204/301/302/308 and drop content only for 204.

For 301, 302 and 308, drop content as for 204, and emit the Location header.

Why

sdk-generator currently has to infer that these methods are browser redirects from the response shape: a 3xx with a non-JSON binary body (Language::getMethodType). Declaring the Location header states it directly, so generators and other OpenAPI tooling can treat these operations as redirects without guessing.

Context: server SDKs currently request these URLs themselves instead of returning them for the browser to open. Since #14012 that breaks server-started OAuth2 sign-in with user_oauth2_state_invalid, because the nonce cookie never reaches the browser. That SDK fix is tracked separately. This issue only covers the spec.

Out of scope

  • sdk-generator changes. getMethodType must switch to "3xx with a Location header" in the same release as this change, otherwise SDKs stop classifying these methods as webAuth.
  • x-appwrite extensions, security schemes, and any other spec changes.

Acceptance criteria

  • Both operations' 301 responses have headers.Location with type: string, format: uri, and no content.
  • The description is no longer "No content" for 3xx responses.
  • 204 responses are unchanged.
  • The spec validates as OpenAPI 3.0.

Activity

  1. added
    product / auth
    product / databases
    product / messaging
    product / sites
    sdk / cli
    on Oct 6, 2026
  2. added a commit that references this issue on Oct 7, 2026
    f5db0d3
  3. removed
    product / databases
    product / messaging
    product / sites
    sdk / cli
    on Nov 5, 2026
  4. Juanmidev1 commented on Nov 11, 2026

    @Juanmidev1

    I'd like to work on this issue.

    I know the contributing guide recommends starting with a good first issue, but there are currently none open in this repo, and the help wanted ones are all being requested by several people and need changes across multiple repos. This issue is small and well scoped (the Location header and the "No content" description in OpenAPI3.php), so it looked like a good way to get started.

    Could you assign it to me?

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

    product / auth

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions