¶ GitLab login
Update Time: 2025-02-18 09:00:47
¶ Preparation
Configure in GitLab Developer Settings (opens new window) and Authing Console (opens new window).
¶ Integrate GitLab Login
¶ Step 1: Add GitLab 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 GitLab after Add Package.
GitLab depends on Guard-iOS 1.4.3 (opens new window) later.
¶ Step 2: Initialize GitLab login
import Guard
import GitLab
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
Authing.start(<#AUTHING_APP_ID#>)
// appId: GitLab ClientID
// redirectURI: GitLab authorization callback page
// scope: empty by default
GitLab.register(appId: <#your_gitlab_appid#>, redirectURI: <#your_gitlab_redirecturi#>, <#your_gitlab_scope#>)
}
¶ Step 3: Initiate GitLab login authorization
¶ GitLab Authorized Login
func login(viewController: UIViewController, completion: @escaping Authing.AuthCompletion) -> Void
parameter
- viewController UIViewController hosting the view
example
GitLab.login(viewController: <#ViewController#>) { code, message, userInfo in
if (code == 200) {
// login successful
// userInfo
}
}
If the developer integrates GitLab login by himself, after getting the AuthorizationCode, he can call the following API in exchange for Authing user information:
¶ Login via GitLab authorization code
func loginByGitLab(_ code: String, completion: @escaping(Int, String?, UserInfo?) -> Void)
parameter
code
GitLab authorization code
example
AuthClient().loginByGitLab(authCode) { code, message, userInfo in
if (code == 200) {
// userInfo: user information
}
}