¶ Slack login
Update Time: 2025-02-18 09:00:47
¶ Preparation
Configure in Slack API Documentation (opens new window) and Authing Console (opens new window), please refer to [Slack Access Preparation](.. /../../guides/connections/social/slack-mobile/README.md).
¶ Integrate Slack login
¶ Step 1: Add Slack 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 Slack after Add Package.
Slack depends on Guard-iOS 1.4.5 (opens new window) later.
¶ Step 2: Initialize Slack login
import Guard
import Slack
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
Authing.start(<#AUTHING_APP_ID#>)
// appId: Slack ClientID
// redirectURI: Slack authorization callback page
// scope: empty by default
Slack.register(appId: <#your_slack_appid#>, redirectURI: <#your_slack_redirecturi#>, scope: <#your_slack_scope#>)
}
¶ Step 3: Initiate Slack login authorization
¶ Slack authorized login
func login(viewController: UIViewController, completion: @escaping Authing.AuthCompletion) -> Void
parameter
- viewController UIViewController hosting the view
example
Slack.login(viewController: <#ViewController#>) { code, message, userInfo in
if (code == 200) {
// login successful
// userInfo
}
}
If the developer integrates Slack login by himself, after getting the AuthorizationCode, he can call the following API in exchange for the Authing user information:
¶ Login via Slack Authorization Code
func loginBySlack(_ code: String, completion: @escaping(Int, String?, UserInfo?) -> Void)
parameter
code
Slack authorization code
example
AuthClient().loginBySlack(authCode) { code, message, userInfo in
if (code == 200) {
// userInfo: user information
}
}