Skip to content

Commit b9e1b8d

Browse files
committed
Mapped some Microsoft Graph authenticator errors
1 parent 7cd3fd4 commit b9e1b8d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Sources/CryptomatorCloudAccess/MicrosoftGraph/MicrosoftGraphAuthenticator.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import UIKit
1515

1616
public enum MicrosoftGraphAuthenticatorError: Error {
1717
case missingAccountIdentifier
18+
case serverDeclinedScopes
19+
case userCanceled
1820
}
1921

2022
public class MicrosoftGraphAuthenticator {
@@ -27,6 +29,15 @@ public class MicrosoftGraphAuthenticator {
2729
throw MicrosoftGraphAuthenticatorError.missingAccountIdentifier
2830
}
2931
return MicrosoftGraphCredential(identifier: identifier, scopes: scopes)
32+
}.recover { error -> MicrosoftGraphCredential in
33+
if let error = error as NSError?, error.domain == MSALErrorDomain {
34+
if error.code == MSALError.serverDeclinedScopes.rawValue {
35+
throw MicrosoftGraphAuthenticatorError.serverDeclinedScopes
36+
} else if error.code == MSALError.userCanceled.rawValue {
37+
throw MicrosoftGraphAuthenticatorError.userCanceled
38+
}
39+
}
40+
throw error
3041
}
3142
}
3243

0 commit comments

Comments
 (0)