Delete superfluous OAuthAcessTokenRefreshRequesting protocol.

This commit is contained in:
Brent Simmons 2024-04-25 12:08:52 -07:00
parent f9a3d8e2c1
commit a3a61989d7
2 changed files with 9 additions and 14 deletions

View File

@ -332,16 +332,22 @@ extension FeedlyAPICaller: OAuthAuthorizationCodeGrantRequesting {
}
}
extension FeedlyAPICaller: OAuthAcessTokenRefreshRequesting {
extension FeedlyAPICaller {
func refreshAccessToken(_ refreshRequest: OAuthRefreshAccessTokenRequest) async throws -> FeedlyOAuthAccessTokenResponse {
/// Access tokens expire. Perform a request for a fresh access token given the long life refresh token received when authorization was granted.
///
/// [Documentation](https://tools.ietf.org/html/rfc6749#section-6)
///
/// - Parameter refreshRequest: The refresh token and other information the authorization server requires to grant the client fresh access tokens on the user's behalf.
/// - Returns: On success, the access token response appropriate for concrete type's service. Both the access and refresh token should be stored, preferably on the Keychain. On failure, throws an Error.
func refreshAccessToken(_ refreshRequest: OAuthRefreshAccessTokenRequest) async throws -> FeedlyOAuthAccessTokenResponse {
guard !isSuspended else { throw TransportError.suspended }
var request = try urlRequest(path: "/v3/auth/token", method: HTTPMethod.post, includeJSONHeaders: true, includeOAuthToken: false)
try addObject(refreshRequest, 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)
}

View File

@ -29,17 +29,6 @@ public struct OAuthRefreshAccessTokenRequest: Encodable, Sendable {
}
}
/// Conformed to by API callers to provide a consistent interface for `AccountDelegate` types to refresh OAuth Access Tokens. 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-6
public protocol OAuthAcessTokenRefreshRequesting {
associatedtype AccessTokenResponse: OAuthAccessTokenResponse
/// Access tokens expire. Perform a request for a fresh access token given the long life refresh token received when authorization was granted.
/// - Parameter refreshRequest: The refresh token and other information the authorization server requires to grant the client fresh access tokens on the user's behalf.
/// - Parameter completion: On success, the access token response appropriate for concrete type's service. Both the access and refresh token should be stored, preferably on the Keychain. On failure, possibly a `URLError` or `OAuthAuthorizationErrorResponse` value.
func refreshAccessToken(_ refreshRequest: OAuthRefreshAccessTokenRequest) async throws -> AccessTokenResponse
}
/// Implemented by concrete types to perform the actual request.
protocol OAuthAccessTokenRefreshing: AnyObject {