Skip to content

[P1] Propagate ASWebAuthenticationSession start failures #36

Description

@DominikPalo

Problem

authorizeEmbedded starts ASWebAuthenticationSession but ignores the returned Bool. On iOS, authenticationSessionEmbedded(...) returns false when the redirect URL cannot be parsed or when ASWebAuthenticationSession.start() fails. On macOS, startAuthenticationSession(...) also returns the start result. In both cases, the caller can continue waiting for an authorization callback that will never arrive.

Affected files

  • Sources/iOS/OAuth2Authorizer+iOS.swift
  • Sources/macOS/OAuth2Authorizer+macOS.swift

Why fix

This can leave try await oauth.authorize() suspended indefinitely. It also makes configuration errors hard to diagnose because the public async API does not throw even though authorization did not start.

Recommended fix

Make the start result part of the throwing control flow. If the redirect URL is invalid or the session does not start, throw a specific OAuth2Error and ensure didFail(with:) resumes any pending continuation. Keep iOS and macOS behavior consistent.

Suggested tests

  • Embedded authorization throws when redirect URL is invalid.
  • Embedded authorization throws or fails callbacks when the authentication session does not start.
  • authorize() never remains pending after a failed session start.

Source: Docs/REVIEW_FINDINGS.md, Task 1.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions