¶ Gitee login
Update Time: 2025-05-14 08:32:28
¶ Preparation
Configure in gitee.com (opens new window) and Authing Console (opens new window).
¶ Integrate Gitee login
¶ Step 1: Add Gitee 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 Gitee after Add Package.
Gitee depends on Guard-iOS 1.4.3 (opens new window) later.
¶ Step 2: Initialize Gitee login
import Guard
import Gitee
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
Authing.start(<#AUTHING_APP_ID#>)
// appId: Gitee ClientID
// redirectURI: Gitee authorization callback page
// scope: defaults to userInfo
Gitee.register(appId: <#your_gitee_appid#>, redirectURI: <#your_gitee_redirecturi#>, <#your_gitee_scope#>)
}
¶ Step 3: Initiate Gitee login authorization
¶ Gitee authorization login
func login(viewController: UIViewController, completion: @escaping Authing.AuthCompletion) -> Void
parameter
- viewController UIViewController hosting the view
example
Gitee.login(viewController: <#ViewController#>) { code, message, userInfo in
if (code == 200) {
// login successful
// userInfo
}
}
If the developer integrates Gitee login by himself, after getting the AuthorizationCode, he can call the following API in exchange for Authing user information:
¶ Login via Gitee authorization code
func loginByGitee(_ code: String, completion: @escaping(Int, String?, UserInfo?) -> Void)
parameter
code
Gitee authorization code
example
AuthClient().loginByGitee(authCode) { code, message, userInfo in
if (code == 200) {
// userInfo: user information
}
}