Skip to content

loginProvider doesn't check HTTP status before decoding token response #60

Description

@ewanc26

Bug

The loginProvider in Bluesky.swift discards the HTTP response status and tries to decode any response body as a TokenResponse.

When a token endpoint returns a 4xx error (e.g., {"error":"invalid_grant"}), it produces a misleading DecodingError: missing key 'access_token' instead of surfacing the actual error.

Affected code:

let (data, _) = try await params.responseProvider(request)
let tokenResponse = try JSONDecoder().decode(TokenResponse.self, from: data)

Fix: Check HTTP status code before decoding, like refreshProvider already does.

Found while integrating OAuthenticator into Inkwell (AT Protocol client for iOS).

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