Delete FeedlyAccountDelegate+OAuth.swift.
This commit is contained in:
parent
0a4be8f49f
commit
e56f7a73b8
|
@ -1,33 +0,0 @@
|
|||
//
|
||||
// FeedlyAccountDelegate+OAuth.swift
|
||||
// Account
|
||||
//
|
||||
// Created by Kiel Gillard on 14/9/19.
|
||||
// Copyright © 2019 Ranchero Software, LLC. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Web
|
||||
import Secrets
|
||||
import Feedly
|
||||
|
||||
extension FeedlyAccountDelegate {
|
||||
|
||||
func refreshAccessToken(with refreshToken: String, client: OAuthAuthorizationClient) async throws -> OAuthAuthorizationGrant {
|
||||
|
||||
let request = OAuthRefreshAccessTokenRequest(refreshToken: refreshToken, scope: nil, client: client)
|
||||
let response = try await caller.refreshAccessToken(request)
|
||||
|
||||
let accessToken = Credentials(type: .oauthAccessToken, username: response.id, secret: response.accessToken)
|
||||
let refreshToken: Credentials? = {
|
||||
guard let token = response.refreshToken else {
|
||||
return nil
|
||||
}
|
||||
return Credentials(type: .oauthRefreshToken, username: response.id, secret: token)
|
||||
}()
|
||||
|
||||
let grant = OAuthAuthorizationGrant(accessToken: accessToken, refreshToken: refreshToken)
|
||||
|
||||
return grant
|
||||
}
|
||||
}
|
|
@ -964,7 +964,7 @@ extension FeedlyAccountDelegate: FeedlyAPICallerDelegate {
|
|||
}
|
||||
|
||||
os_log(.debug, log: log, "Refreshing access token.")
|
||||
let grant = try await refreshAccessToken(with: credentials.secret, client: oauthAuthorizationClient)
|
||||
let grant = try await caller.refreshAccessToken(with: credentials.secret, client: oauthAuthorizationClient)
|
||||
|
||||
os_log(.debug, log: log, "Storing refresh token.")
|
||||
if let refreshToken = grant.refreshToken {
|
||||
|
|
|
@ -617,6 +617,23 @@ extension FeedlyAPICaller {
|
|||
|
||||
return grant
|
||||
}
|
||||
|
||||
public func refreshAccessToken(with refreshToken: String, client: OAuthAuthorizationClient) async throws -> OAuthAuthorizationGrant {
|
||||
|
||||
let request = OAuthRefreshAccessTokenRequest(refreshToken: refreshToken, scope: nil, client: client)
|
||||
let response = try await refreshAccessToken(request)
|
||||
|
||||
let accessToken = Credentials(type: .oauthAccessToken, username: response.id, secret: response.accessToken)
|
||||
let refreshToken: Credentials? = {
|
||||
guard let token = response.refreshToken else {
|
||||
return nil
|
||||
}
|
||||
return Credentials(type: .oauthRefreshToken, username: response.id, secret: token)
|
||||
}()
|
||||
|
||||
let grant = OAuthAuthorizationGrant(accessToken: accessToken, refreshToken: refreshToken)
|
||||
return grant
|
||||
}
|
||||
}
|
||||
|
||||
private extension FeedlyAPICaller {
|
||||
|
|
Loading…
Reference in New Issue