Move more OAuth code to Feedly module.

This commit is contained in:
Brent Simmons 2024-04-25 19:55:39 -07:00
parent 2e6ce552b9
commit ed957d92cf
5 changed files with 14 additions and 18 deletions

View File

@ -20,6 +20,7 @@ import os.log
import Secrets
import Core
import CommonErrors
import Feedly
// Main thread only.

View File

@ -9,10 +9,14 @@
import Foundation
import Web
import Secrets
import Feedly
/// Models the access token response from Feedly.
/// https://developer.feedly.com/v3/auth/#exchanging-an-auth-code-for-a-refresh-token-and-an-access-token
public struct FeedlyOAuthAccessTokenResponse: Decodable, OAuthAccessTokenResponse, Sendable {
/// <https://developer.feedly.com/v3/auth/#exchanging-an-auth-code-for-a-refresh-token-and-an-access-token>
///
/// Also see: <https://tools.ietf.org/html/rfc6749#section-4.1.4>
public struct FeedlyOAuthAccessTokenResponse: Decodable, Sendable {
/// The ID of the Feedly user.
public var id: String

View File

@ -9,7 +9,6 @@
import Foundation
import Web
import Secrets
import Feedly
/// Client-specific information for requesting an authorization code grant.
/// Accounts are responsible for the scope.
@ -131,20 +130,14 @@ public struct OAuthAccessTokenRequest: Encodable, Sendable {
}
}
/// Models the minimum subset of properties of a response in section 4.1.4 of the OAuth 2.0 Authorization Framework
/// Concrete types model other parameters beyond the scope of the OAuth spec.
/// For example, Feedly provides the ID of the user who has consented to the grant.
/// https://tools.ietf.org/html/rfc6749#section-4.1.4
public protocol OAuthAccessTokenResponse {
var accessToken: String { get }
var tokenType: String { get }
var expiresIn: Int { get }
var refreshToken: String? { get }
var scope: String { get }
}
/// The access and refresh tokens from a successful authorization grant.
public struct OAuthAuthorizationGrant: Equatable {
public var accessToken: Credentials
public var refreshToken: Credentials?
public init(accessToken: Credentials, refreshToken: Credentials? = nil) {
self.accessToken = accessToken
self.refreshToken = refreshToken
}
}

View File

@ -8,9 +8,8 @@
import Foundation
import Secrets
import Feedly
extension OAuthAuthorizationClient {
public extension OAuthAuthorizationClient {
static func feedlyCloudClient(secretsProvider: SecretsProvider) -> OAuthAuthorizationClient {
/// Models private NetNewsWire client secrets.

View File

@ -8,7 +8,6 @@
import Foundation
import Web
import Feedly
/// Models section 6 of the OAuth 2.0 Authorization Framework
/// https://tools.ietf.org/html/rfc6749#section-6