Skip to content

Commit 7c46761

Browse files
committed
Remove deprecated iOS code
Remove also the legacy implementation of `OAuth2CodeGrantLinkedIn` as it depends on no longer supported custom view controller on iOS
1 parent 6ab2098 commit 7c46761

File tree

6 files changed

+5
-147
lines changed

6 files changed

+5
-147
lines changed

OAuth2.xcodeproj/project.pbxproj

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
659854531C5B3CA700237D39 /* OAuth2ImplicitGrant.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE3174EB1945E83100210E62 /* OAuth2ImplicitGrant.swift */; };
1818
659854541C5B3CA700237D39 /* OAuth2CodeGrant.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE44F691194F2C7D0094AB8B /* OAuth2CodeGrant.swift */; };
1919
659854551C5B3CA700237D39 /* OAuth2CodeGrantFacebook.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEACE1DE1A7E8FC1009BF3A7 /* OAuth2CodeGrantFacebook.swift */; };
20-
659854561C5B3CA700237D39 /* OAuth2CodeGrantLinkedIn.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEC6D57B1C2837EA00FA9B1C /* OAuth2CodeGrantLinkedIn.swift */; };
2120
659854571C5B3CA700237D39 /* OAuth2CodeGrantBasicAuth.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE1391D91AC5B41A002C7B18 /* OAuth2CodeGrantBasicAuth.swift */; };
2221
659854581C5B3CA700237D39 /* OAuth2CodeGrantNoTokenType.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE86C4641C48F6AC00B7D486 /* OAuth2CodeGrantNoTokenType.swift */; };
2322
659854591C5B3CA700237D39 /* OAuth2ClientCredentials.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE5F4F851B19114D00DB38B3 /* OAuth2ClientCredentials.swift */; };
@@ -121,8 +120,6 @@
121120
EEC49F311C9BF22400989A18 /* OAuth2AuthRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEC49F301C9BF22400989A18 /* OAuth2AuthRequest.swift */; };
122121
EEC49F321C9BF22400989A18 /* OAuth2AuthRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEC49F301C9BF22400989A18 /* OAuth2AuthRequest.swift */; };
123122
EEC49F331C9BF22400989A18 /* OAuth2AuthRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEC49F301C9BF22400989A18 /* OAuth2AuthRequest.swift */; };
124-
EEC6D57C1C2837EA00FA9B1C /* OAuth2CodeGrantLinkedIn.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEC6D57B1C2837EA00FA9B1C /* OAuth2CodeGrantLinkedIn.swift */; };
125-
EEC6D57D1C2837EA00FA9B1C /* OAuth2CodeGrantLinkedIn.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEC6D57B1C2837EA00FA9B1C /* OAuth2CodeGrantLinkedIn.swift */; };
126123
EEC7A8C71AE46C33008C30E7 /* OAuth2Authorizer+macOS.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEC7A8C61AE46C33008C30E7 /* OAuth2Authorizer+macOS.swift */; };
127124
EEC7A8C91AE47111008C30E7 /* OAuth2Authorizer+iOS.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEC7A8C81AE47111008C30E7 /* OAuth2Authorizer+iOS.swift */; };
128125
EEF47D2B1B1E3FDD0057D838 /* OAuth2Requestable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEF47D2A1B1E3FDD0057D838 /* OAuth2Requestable.swift */; };
@@ -232,7 +229,6 @@
232229
EEB9A97F1D86CD4A0022EF66 /* OAuth2DataLoaderTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OAuth2DataLoaderTests.swift; sourceTree = "<group>"; };
233230
EEB9A9821D86D36A0022EF66 /* OAuth2RequestPerformer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OAuth2RequestPerformer.swift; sourceTree = "<group>"; };
234231
EEC49F301C9BF22400989A18 /* OAuth2AuthRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = OAuth2AuthRequest.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
235-
EEC6D57B1C2837EA00FA9B1C /* OAuth2CodeGrantLinkedIn.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OAuth2CodeGrantLinkedIn.swift; sourceTree = "<group>"; };
236232
EEC7A8C61AE46C33008C30E7 /* OAuth2Authorizer+macOS.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = "OAuth2Authorizer+macOS.swift"; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
237233
EEC7A8C81AE47111008C30E7 /* OAuth2Authorizer+iOS.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = "OAuth2Authorizer+iOS.swift"; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
238234
EEC7A8E01AE48533008C30E7 /* LICENSE.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = LICENSE.txt; sourceTree = "<group>"; };
@@ -377,7 +373,6 @@
377373
0C2F5E5A1DE2DB8500F621E0 /* OAuth2CodeGrantAzure.swift */,
378374
EE1391D91AC5B41A002C7B18 /* OAuth2CodeGrantBasicAuth.swift */,
379375
EEACE1DE1A7E8FC1009BF3A7 /* OAuth2CodeGrantFacebook.swift */,
380-
EEC6D57B1C2837EA00FA9B1C /* OAuth2CodeGrantLinkedIn.swift */,
381376
EE86C4641C48F6AC00B7D486 /* OAuth2CodeGrantNoTokenType.swift */,
382377
8793811829D483EC00DC4EBC /* OAuth2DeviceGrant.swift */,
383378
EE507A371B1E15E000AE02E9 /* OAuth2DynReg.swift */,
@@ -703,7 +698,6 @@
703698
EE429D8E1E65721000BC6F67 /* OAuth2CustomAuthorizer+tvOS.swift in Sources */,
704699
659854551C5B3CA700237D39 /* OAuth2CodeGrantFacebook.swift in Sources */,
705700
EEB9A9851D86D36A0022EF66 /* OAuth2RequestPerformer.swift in Sources */,
706-
659854561C5B3CA700237D39 /* OAuth2CodeGrantLinkedIn.swift in Sources */,
707701
6598545D1C5B3CAB00237D39 /* OAuth2Error.swift in Sources */,
708702
EE2983721D40B83600933CDD /* OAuth2.swift in Sources */,
709703
EE20118E1E44D0BD00913FA7 /* OAuth2DataLoaderSessionTaskDelegate.swift in Sources */,
@@ -735,7 +729,6 @@
735729
EEF47D2C1B1E3FDD0057D838 /* OAuth2Requestable.swift in Sources */,
736730
EEC49F321C9BF22400989A18 /* OAuth2AuthRequest.swift in Sources */,
737731
8793811A29D483EC00DC4EBC /* OAuth2DeviceGrant.swift in Sources */,
738-
EEC6D57D1C2837EA00FA9B1C /* OAuth2CodeGrantLinkedIn.swift in Sources */,
739732
EE79F6551BFA93D900746243 /* OAuth2AuthConfig.swift in Sources */,
740733
EEACE1D51A7E8DE8009BF3A7 /* OAuth2Base.swift in Sources */,
741734
879EE6F02CF61295008B3D74 /* OAuth2ResponseTypes.swift in Sources */,
@@ -802,7 +795,6 @@
802795
EE86C4651C48F6AC00B7D486 /* OAuth2CodeGrantNoTokenType.swift in Sources */,
803796
EE20118C1E44D0BD00913FA7 /* OAuth2DataLoaderSessionTaskDelegate.swift in Sources */,
804797
EEACE1DF1A7E8FC1009BF3A7 /* OAuth2CodeGrantFacebook.swift in Sources */,
805-
EEC6D57C1C2837EA00FA9B1C /* OAuth2CodeGrantLinkedIn.swift in Sources */,
806798
EE1391DA1AC5B41A002C7B18 /* OAuth2CodeGrantBasicAuth.swift in Sources */,
807799
EA9758181B222CEA007744B1 /* OAuth2PasswordGrant.swift in Sources */,
808800
EE507A381B1E15E000AE02E9 /* OAuth2DynReg.swift in Sources */,

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,6 @@ let oauth2 = OAuth2CodeGrant(settings: [
374374
- [Facebook](https://github.com/p2/OAuth2/wiki/Facebook)
375375
- [Reddit](https://github.com/p2/OAuth2/wiki/Reddit)
376376
- [Google](https://github.com/p2/OAuth2/wiki/Google)
377-
- [LinkedIn](https://github.com/p2/OAuth2/wiki/LinkedIn)
378377
- [Instagram, Bitly, Pinterest, ...](https://github.com/p2/OAuth2/wiki/Instagram,-Bitly,-Pinterest-and-others)
379378
- [Uber](https://github.com/p2/OAuth2/wiki/Uber)
380379
- [BitBucket](https://github.com/p2/OAuth2/wiki/BitBucket)

Sources/Base/OAuth2AuthConfig.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@ public struct OAuth2AuthConfig: Sendable {
3434
/// Title to propagate to views handled by OAuth2, such as OAuth2WebViewController.
3535
public var title: String? = nil
3636

37-
/// Starting with iOS 9, `SFSafariViewController` will be used for embedded authorization instead of our custom class. You can turn this off here.
38-
public var useSafariView = false
39-
4037
/// Starting with iOS 12, `ASWebAuthenticationSession` can be used for embedded authorization instead of our custom class. You can turn this on here.
4138
public var useAuthenticationSession = true
4239

Sources/Flows/OAuth2CodeGrantLinkedIn.swift

Lines changed: 0 additions & 45 deletions
This file was deleted.

Sources/iOS/OAuth2Authorizer+iOS.swift

Lines changed: 5 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -99,21 +99,11 @@ open class OAuth2Authorizer: OAuth2AuthorizerUI {
9999
throw (nil == config.authorizeContext) ? OAuth2Error.noAuthorizationContext : OAuth2Error.invalidAuthorizationContext
100100
}
101101

102-
if config.ui.useSafariView {
103-
let web = try authorizeSafariEmbedded(from: controller, at: url)
104-
if config.authorizeEmbeddedAutoDismiss {
105-
oauth2.internalAfterAuthorizeOrFail = { wasFailure, error in
106-
self.safariViewDelegate = nil
107-
web.dismiss(animated: true)
108-
}
109-
}
110-
}
111-
else {
112-
let web = try authorizeEmbedded(from: controller, at: url)
113-
if config.authorizeEmbeddedAutoDismiss {
114-
oauth2.internalAfterAuthorizeOrFail = { wasFailure, error in
115-
web.dismiss(animated: true)
116-
}
102+
let web = try authorizeSafariEmbedded(from: controller, at: url)
103+
if config.authorizeEmbeddedAutoDismiss {
104+
oauth2.internalAfterAuthorizeOrFail = { wasFailure, error in
105+
self.safariViewDelegate = nil
106+
web.dismiss(animated: true)
117107
}
118108
}
119109
#endif
@@ -237,72 +227,6 @@ open class OAuth2Authorizer: OAuth2AuthorizerUI {
237227
safariViewDelegate = nil
238228
oauth2.didFail(with: nil)
239229
}
240-
241-
242-
// MARK: - Custom Web View Controller
243-
244-
/**
245-
Presents a web view controller, contained in a UINavigationController, on the supplied view controller and loads the authorize URL.
246-
247-
Automatically intercepts the redirect URL and performs the token exchange. It does NOT however dismiss the web view controller
248-
automatically, you probably want to do this in the callback. Simply call this method first, then assign that closure in which you call
249-
`dismissViewController()` on the returned web view controller instance.
250-
251-
- parameter from: The view controller to use for presentation
252-
- parameter at: The authorize URL to open
253-
- returns: OAuth2WebViewController, embedded in a UINavigationController being presented automatically
254-
*/
255-
@available(*, deprecated, message: "Use ASWebAuthenticationSession (preferred) or SFSafariWebViewController. This will be removed in v6.")
256-
public func authorizeEmbedded(from controller: UIViewController, at url: URL) throws -> OAuth2WebViewController {
257-
guard let redirect = oauth2.redirect else {
258-
throw OAuth2Error.noRedirectURL
259-
}
260-
return presentAuthorizeView(forURL: url, intercept: redirect, from: controller)
261-
}
262-
263-
/**
264-
Presents and returns a web view controller loading the given URL and intercepting the given URL.
265-
266-
- returns: OAuth2WebViewController, embedded in a UINavigationController being presented automatically
267-
*/
268-
@available(*, deprecated, message: "Use ASWebAuthenticationSession (preferred) or SFSafariWebViewController. This will be removed in v6.")
269-
final func presentAuthorizeView(forURL url: URL, intercept: String, from controller: UIViewController) -> OAuth2WebViewController {
270-
let web = OAuth2WebViewController()
271-
web.title = oauth2.authConfig.ui.title
272-
web.backButton = oauth2.authConfig.ui.backButton as? UIBarButtonItem
273-
web.showCancelButton = oauth2.authConfig.ui.showCancelButton
274-
web.startURL = url
275-
web.interceptURLString = intercept
276-
web.onIntercept = { url in
277-
do {
278-
try self.oauth2.handleRedirectURL(url as URL)
279-
return true
280-
}
281-
catch let err {
282-
self.oauth2.logger?.warn("OAuth2", msg: "Cannot intercept redirect URL: \(err)")
283-
}
284-
return false
285-
}
286-
web.onWillDismiss = { didCancel in
287-
if didCancel {
288-
self.oauth2.didFail(with: nil)
289-
}
290-
}
291-
292-
let navi = UINavigationController(rootViewController: web)
293-
navi.modalPresentationStyle = oauth2.authConfig.ui.modalPresentationStyle
294-
if let barTint = oauth2.authConfig.ui.barTintColor {
295-
navi.navigationBar.barTintColor = barTint
296-
}
297-
if let tint = oauth2.authConfig.ui.controlTintColor {
298-
navi.navigationBar.tintColor = tint
299-
}
300-
301-
willPresent(viewController: web, in: navi)
302-
controller.present(navi, animated: true)
303-
304-
return web
305-
}
306230
#endif
307231
}
308232

Tests/FlowTests/OAuth2CodeGrantTests.swift

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -402,15 +402,6 @@ class OAuth2CodeGrantTests: XCTestCase {
402402
XCTAssertNil(error, "Should not throw wrong error")
403403
}
404404

405-
// LinkedIn on the other hand must not throw
406-
let linkedin = OAuth2CodeGrantLinkedIn(settings: settings)
407-
do {
408-
_ = try linkedin.parseAccessTokenResponse(params: response)
409-
}
410-
catch let error {
411-
XCTAssertNil(error, "Should not throw")
412-
}
413-
414405
// Nor the generic no-token-type class
415406
let noType = OAuth2CodeGrantNoTokenType(settings: settings)
416407
do {

0 commit comments

Comments
 (0)