¶ LinkedIn login
Update Time: 2025-05-14 08:32:28
¶ Preparation
Configure in Linkedin Developer Center (opens new window) and Authing Console (opens new window).
¶ Integrated LinkedIn Login
¶ Step 1: Add Linkedin dependency
Enter: https://github.com/Authing/authing-binary in the swift package search bar.
Authing-binary (opens new window) depends on Guard-iOS SDK (opens new window).
Select Up to Next Major Version 1.0.0 for the dependency rule.
Check Linkedin after Add Package.
Linkedin depends on the version after Guard-iOS 1.4.3 (opens new window).
¶ Step 2: Initialize LinkedIn Login
import Guard
import Linkedin
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
Authing.start(<#AUTHING_APP_ID#>)
// clientId: LinkedIn console clientId
// permissions: LinkedIn console OAuth 2.0 scopes, for example: r_liteprofile
// redirectURI: LinkedIn console authorization callback page
Linkedin.register(clientId: <#your_linkedin_clientId#>, permissions: <#your_linkedin_scopes#>, redirectURI: <#your_linkedin_redirecturi#>)
}
¶ Step 3: Initiate LinkedIn login authorization
¶ LinkedIn Authorized Login
func login(viewController: UIViewController, completion: @escaping Authing.AuthCompletion) -> Void
parameter
- viewController AuthViewController hosting the view
example
Linkedin.login(viewController: <#ViewController#>) { code, message, userInfo in
if (code == 200) {
// login successful
// userInfo
}
}
If the developer integrates LinkedIn login by himself, after getting the AuthorizationCode, he can call the following API in exchange for Authing user information:
¶ Login via LinkedIn Authorization Code
func loginByLinkedin(_ code: String, completion: @escaping(Int, String?, UserInfo?) -> Void)
parameter
code
LinkedIn authorization code
example
AuthClient().loginByLinkedin(authCode) { code, message, userInfo in
if (code == 200) {
// userInfo: user information
}
}