diff --git a/Sources/LinkedIn/LinkedInAuthenticator+Models.swift b/Sources/LinkedIn/LinkedInAuthenticator+Models.swift index 4383ea7..4ce7cb5 100644 --- a/Sources/LinkedIn/LinkedInAuthenticator+Models.swift +++ b/Sources/LinkedIn/LinkedInAuthenticator+Models.swift @@ -14,20 +14,42 @@ public extension LinkedInAuthenticator { let clientSecret: String let permissions: String let redirectUrl: URL - let authEndpoint: URL = "https://www.linkedin.com/oauth/v2/authorization" - let authCancel: URL = "https://www.linkedin.com/oauth/v2/login-cancel" + var authEndpoint: URL = "https://www.linkedin.com/oauth/v2/authorization" + var authCancel: URL = "https://www.linkedin.com/oauth/v2/login-cancel" - public init(clientId: String, clientSecret: String, permissions: String, redirectUrl: URL) { + public init( + clientId: String, + clientSecret: String, + permissions: String, + redirectUrl: URL + ) { self.clientId = clientId self.clientSecret = clientSecret self.permissions = permissions self.redirectUrl = redirectUrl } + public init( + clientId: String, + clientSecret: String, + permissions: String, + redirectUrl: URL, + authEndpoint: URL, + authCancel: URL + ) { + self.clientId = clientId + self.clientSecret = clientSecret + self.permissions = permissions + self.redirectUrl = redirectUrl + self.authEndpoint = authEndpoint + self.authCancel = authCancel + } + func authorizationUrl(state: String) -> URL? { guard var urlComponents = URLComponents(url: authEndpoint, resolvingAgainstBaseURL: false) else { return nil } urlComponents.queryItems = [ .init(name: "response_type", value: "code"), + .init(name: "connection", value: "linkedin"), .init(name: "client_id", value: clientId), .init(name: "redirect_uri", value: redirectUrl.absoluteString), .init(name: "state", value: state), diff --git a/Sources/LinkedIn/WebView/LinkedInSheet.swift b/Sources/LinkedIn/WebView/LinkedInSheet.swift index aaf96fd..92d5a0d 100644 --- a/Sources/LinkedIn/WebView/LinkedInSheet.swift +++ b/Sources/LinkedIn/WebView/LinkedInSheet.swift @@ -8,15 +8,15 @@ import SwiftUI @available(iOS 15.0, *) -struct LinkedInSheet: ViewModifier { - typealias SuccessHandler = LinkedInWebView.SuccessHandler // (Bool) -> Void - typealias ErrorHandler = LinkedInWebView.ErrorHandler // (Error) -> Void - let config: LinkedInAuthenticator.Configuration - let isPresented: Binding - let onSuccess: SuccessHandler? - let onError: ErrorHandler? +public struct LinkedInSheet: ViewModifier { + public typealias SuccessHandler = LinkedInWebView.SuccessHandler // (Bool) -> Void + public typealias ErrorHandler = LinkedInWebView.ErrorHandler // (Error) -> Void + public let config: LinkedInAuthenticator.Configuration + public let isPresented: Binding + public let onSuccess: SuccessHandler? + public let onError: ErrorHandler? - func body(content: Content) -> some View { + public func body(content: Content) -> some View { content .sheet(isPresented: isPresented) { LinkedInWebView(with: config) { data in @@ -29,7 +29,7 @@ struct LinkedInSheet: ViewModifier { } @available(iOS 15.0, *) -extension View { +public extension View { /// ViewModifier to present `LinkedInWebView` in sheet func linkedInSheet(with config: LinkedInAuthenticator.Configuration, isPresented: Binding,