Skip to content

Commit

Permalink
+1
Browse files Browse the repository at this point in the history
  • Loading branch information
borut-t committed Sep 19, 2023
1 parent 246f570 commit 8799d11
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions Sources/LinkedIn/LinkedInAuthenticator+Models.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +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
) {
self.clientId = clientId
self.clientSecret = clientSecret
self.permissions = permissions
self.redirectUrl = redirectUrl
}

public init(
clientId: String,
clientSecret: String,
permissions: String,
redirectUrl: URL,
authEndpoint: URL? = nil,
authCancel: URL? = nil
authEndpoint: URL,
authCancel: URL
) {
self.clientId = clientId
self.clientSecret = clientSecret
self.permissions = permissions
self.redirectUrl = redirectUrl
self.authEndpoint = authEndpoint ?? "https://www.linkedin.com/oauth/v2/authorization"
self.authCancel = authCancel ?? "https://www.linkedin.com/oauth/v2/login-cancel"
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),
Expand Down

0 comments on commit 8799d11

Please sign in to comment.