Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Sources/InfomaniakCore/Networking/ApiFetcher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ open class OAuthAuthenticator: Authenticator {

public weak var refreshTokenDelegate: RefreshTokenDelegate?

public init(refreshTokenDelegate: RefreshTokenDelegate) {
public init(refreshTokenDelegate: RefreshTokenDelegate?) {
self.refreshTokenDelegate = refreshTokenDelegate
}

Expand All @@ -284,6 +284,9 @@ open class OAuthAuthenticator: Authenticator {
if let error = error as NSError?, error.domain == "invalid_grant" {
self.refreshTokenDelegate?.didFailRefreshToken(credential)
completion(.failure(error))
} else if let loginError = error as? InfomaniakLoginError,
case .noRefreshToken = loginError {
completion(.failure(loginError))
} else {
// Couldn't refresh the token, keep the old token and fetch it later. Maybe because of bad network ?
completion(.success(credential))
Expand Down
Loading