diff --git a/Account/Sources/Account/Feedly/FeedlyAPICaller.swift b/Account/Sources/Account/Feedly/FeedlyAPICaller.swift index daaf47f0a..5b63b0421 100644 --- a/Account/Sources/Account/Feedly/FeedlyAPICaller.swift +++ b/Account/Sources/Account/Feedly/FeedlyAPICaller.swift @@ -294,8 +294,13 @@ extension FeedlyAPICaller: FeedlyAddFeedToCollectionService { } } -extension FeedlyAPICaller: OAuthAuthorizationCodeGrantRequesting { +extension FeedlyAPICaller { + /// https://tools.ietf.org/html/rfc6749#section-4.1 + + /// Provides the URL request that allows users to consent to the client having access to their information. Typically loaded by a web view. + /// - Parameter request: The information about the client requesting authorization to be granted access tokens. + /// - Parameter baseUrlComponents: The scheme and host of the url except for the path. static func authorizationCodeURLRequest(for request: OAuthAuthorizationRequest, baseUrlComponents: URLComponents) -> URLRequest { var components = baseUrlComponents @@ -314,8 +319,9 @@ extension FeedlyAPICaller: OAuthAuthorizationCodeGrantRequesting { return request } - typealias AccessTokenResponse = FeedlyOAuthAccessTokenResponse - + /// Performs the request for the access token given an authorization code. + /// - Parameter authorizationRequest: The authorization code and other information the authorization server requires to grant the client access tokens on the user's behalf. + /// - Returns: On success, the access token response appropriate for concrete type's service. On failure, throws possibly a `URLError` or `OAuthAuthorizationErrorResponse` value. func requestAccessToken(_ authorizationRequest: OAuthAccessTokenRequest) async throws -> FeedlyOAuthAccessTokenResponse { guard !isSuspended else { throw TransportError.suspended } @@ -323,7 +329,7 @@ extension FeedlyAPICaller: OAuthAuthorizationCodeGrantRequesting { var request = try urlRequest(path: "/v3/auth/token", method: HTTPMethod.post, includeJSONHeaders: true, includeOAuthToken: false) try addObject(authorizationRequest, keyEncodingStrategy: .convertToSnakeCase, to: &request) - let (_, tokenResponse) = try await send(request: request, resultType: AccessTokenResponse.self) + let (_, tokenResponse) = try await send(request: request, resultType: FeedlyOAuthAccessTokenResponse.self) guard let tokenResponse else { throw URLError(.cannotDecodeContentData) } diff --git a/Account/Sources/Account/Feedly/OAuthAuthorizationCodeGranting.swift b/Account/Sources/Account/Feedly/OAuthAuthorizationCodeGranting.swift index 4fa9f379e..56b4b76d0 100644 --- a/Account/Sources/Account/Feedly/OAuthAuthorizationCodeGranting.swift +++ b/Account/Sources/Account/Feedly/OAuthAuthorizationCodeGranting.swift @@ -148,20 +148,3 @@ public struct OAuthAuthorizationGrant: Equatable { public var accessToken: Credentials public var refreshToken: Credentials? } - -/// Conformed to by API callers to provide a consistent interface for `AccountDelegate` types to enable OAuth Authorization Grants. Conformers provide an associated type that models any custom parameters/properties, as well as the standard ones, in the response to a request for an access token. -/// https://tools.ietf.org/html/rfc6749#section-4.1 -public protocol OAuthAuthorizationCodeGrantRequesting { - associatedtype AccessTokenResponse: OAuthAccessTokenResponse - - /// Provides the URL request that allows users to consent to the client having access to their information. Typically loaded by a web view. - /// - Parameter request: The information about the client requesting authorization to be granted access tokens. - /// - Parameter baseUrlComponents: The scheme and host of the url except for the path. - @MainActor static func authorizationCodeURLRequest(for request: OAuthAuthorizationRequest, baseUrlComponents: URLComponents) -> URLRequest - - - /// Performs the request for the access token given an authorization code. - /// - Parameter authorizationRequest: The authorization code and other information the authorization server requires to grant the client access tokens on the user's behalf. - /// - Returns: On success, the access token response appropriate for concrete type's service. On failure, throws possibly a `URLError` or `OAuthAuthorizationErrorResponse` value. - func requestAccessToken(_ authorizationRequest: OAuthAccessTokenRequest) async throws -> FeedlyOAuthAccessTokenResponse -}