### Install Libraries with CocoaPods Source: https://github.com/naver/naveridlogin-sdk-ios-swift/blob/main/README.md After modifying the Podfile, run this command in your project directory to install the specified libraries. Ensure you have CocoaPods installed. ```shell $ pod install ``` -------------------------------- ### Initialize SDK — NidOAuth.shared.initialize Source: https://context7.com/naver/naveridlogin-sdk-ios-swift/llms.txt Call this method once at the start of your app, typically in `AppDelegate.didFinishLaunchingWithOptions`. Ensure you provide your app's name, client ID, client secret, and URL scheme registered with Naver Developers. ```swift import UIKit import NidThirdPartyLogin @main class AppDelegate: UIResponder, UIApplicationDelegate { func application( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool { NidOAuth.shared.initialize( appName: "MyApp", // 네이버 개발자 센터에 등록한 앱 이름 clientId: "YOUR_CLIENT_ID", clientSecret: "YOUR_CLIENT_SECRET", urlScheme: "myapp" // Info.plist에 등록한 URL Scheme ) return true } } ``` -------------------------------- ### SDK 초기화 — NidOAuth.shared.initialize(appName:clientId:clientSecret:urlScheme:) Source: https://context7.com/naver/naveridlogin-sdk-ios-swift/llms.txt Initializes the SDK with your application's credentials. This method must be called once at the start of your app, typically in `AppDelegate.didFinishLaunchingWithOptions`. ```APIDOC ## SDK 초기화 — `NidOAuth.shared.initialize(appName:clientId:clientSecret:urlScheme:)` ### Description Initializes the SDK with your application's credentials. This method must be called once at the start of your app, typically in `AppDelegate.didFinishLaunchingWithOptions`. ### Method `initialize(appName: String, clientId: String, clientSecret: String, urlScheme: String)` ### Parameters - **appName** (String) - Required - The name of your app registered on the Naver Developers Center. - **clientId** (String) - Required - Your application's client ID. - **clientSecret** (String) - Required - Your application's client secret. - **urlScheme** (String) - Required - The URL scheme registered in your app's `Info.plist`. ### Request Example ```swift // AppDelegate.swift import UIKit import NidThirdPartyLogin @main class AppDelegate: UIResponder, UIApplicationDelegate { func application( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool { NidOAuth.shared.initialize( appName: "MyApp", // 네이버 개발자 센터에 등록한 앱 이름 clientId: "YOUR_CLIENT_ID", clientSecret: "YOUR_CLIENT_SECRET", urlScheme: "myapp" // Info.plist에 등록한 URL Scheme ) return true } } ``` ``` -------------------------------- ### Configure Podfile for CocoaPods Source: https://github.com/naver/naveridlogin-sdk-ios-swift/blob/main/README.md Modify your Podfile to include the 'NidThirdPartyLogin' pod. Replace 'YOUR_APP_TARGET' with the actual target name in your project. This setup is for integrating the SDK using CocoaPods. ```ruby use_frameworks! target 'YOUR_APP_TARGET' do pod 'NidThirdPartyLogin' end ``` -------------------------------- ### Get User Profile Source: https://context7.com/naver/naveridlogin-sdk-ios-swift/llms.txt Retrieves user profile information from the Naver Open API using a valid access token. The result is returned as a dictionary where keys are profile item names and values are their corresponding strings. ```APIDOC ## Get User Profile ### Description Retrieves user profile information from the Naver Open API using a valid access token. ### Method Signature `NidOAuth.shared.getUserProfile(accessToken:callback:)` ### Parameters - `accessToken` (String): The valid access token. - `callback` ((Result<[String: String], NidError>) -> Void): A closure that receives the user profile information or an error. ### Response Example ```swift // 반환 예시: ["name": "홍길동", "email": "user@naver.com", "nickname": "길동이", ...] ``` ### Request Example ```swift import NidThirdPartyLogin guard let tokenString = NidOAuth.shared.accessToken?.tokenString else { print("액세스 토큰이 없습니다.") return } NidOAuth.shared.getUserProfile(accessToken: tokenString) { result in switch result { case .success(let profile): for (key, value) in profile { print("\(key): \(value)") } case .failure(let error): print("프로필 조회 실패: \(error.errorDescription ?? "")") } } ``` ``` -------------------------------- ### Set Login Behavior — NidOAuth.shared.setLoginBehavior Source: https://context7.com/naver/naveridlogin-sdk-ios-swift/llms.txt Specifies the login method using the `LoginBehavior` enum. The default is `.appPreferredWithInAppBrowserFallback`, which prioritizes the Naver app and falls back to the in-app browser if the app is not installed. ```swift import NidThirdPartyLogin // 세 가지 LoginBehavior 옵션: // .app → 항상 네이버 앱으로 로그인 (미설치 시 오류) // .inAppBrowser → 항상 인앱 브라우저로 로그인 // .appPreferredWithInAppBrowserFallback → 앱 우선, 없으면 브라우저 (기본값) NidOAuth.shared.setLoginBehavior(.inAppBrowser) // 이후 requestLogin 호출 시 인앱 브라우저를 통해 로그인 진행 NidOAuth.shared.requestLogin { result in switch result { case .success(let loginResult): print("인앱 브라우저 로그인 성공: \(loginResult.accessToken.tokenString)") case .failure(let error): print("오류: \(error)") } } ``` -------------------------------- ### Handle Naver Login Errors with NidError Source: https://context7.com/naver/naveridlogin-sdk-ios-swift/llms.txt This snippet demonstrates how to handle various client and server errors that can occur during the Naver login process using the NidError enum. It covers common scenarios like user cancellation, missing app installation, initialization issues, and network or authentication failures. ```swift import NidThirdPartyLogin NidOAuth.shared.requestLogin { result in switch result { case .success(let loginResult): print("성공: \(loginResult.accessToken.tokenString)") case .failure(let error): switch error { // 클라이언트 오류 case .clientError(.canceledByUser): print("사용자가 로그인을 취소했습니다.") case .clientError(.naverAppNotInstalled): print("네이버 앱이 설치되어 있지 않습니다.") case .clientError(.initalizeNotCalled): print("initialize()를 먼저 호출해야 합니다.") case .clientError(.multipleInitalizationAttempt): print("initialize()가 중복 호출되었습니다.") case .clientError(.missingClientConfiguration): print("클라이언트 설정값이 누락되었습니다.") case .clientError(.invalidClientConfigurationFormat): print("클라이언트 설정값 형식이 잘못되었습니다.") case .clientError(.unsupportedResponseType): print("지원하지 않는 응답 형식입니다.") // 서버 오류 case .serverError(.networkError(let underlying)): print("네트워크 오류: \(underlying?.localizedDescription ?? \"알 수 없음\")") case .serverError(.authError(let code, let description)): print("인증 오류 — 코드: \(code), 설명: \(description ?? \"없음\")") case .serverError(.invalidState(let expected, let actual)): print("상태 불일치 — 예상: \(expected), 실제: \(actual ?? \"nil\")") default: print("기타 오류: \(error.errorDescription ?? error.description)") } } } ``` -------------------------------- ### Get User Profile with NidOAuth.shared.getUserProfile Source: https://context7.com/naver/naveridlogin-sdk-ios-swift/llms.txt Retrieves user profile information from Naver Open API using a valid access token. The result is a dictionary of profile item names to their values. Ensure an access token is available before calling. ```swift import NidThirdPartyLogin guard let tokenString = NidOAuth.shared.accessToken?.tokenString else { print("액세스 토큰이 없습니다.") return } NidOAuth.shared.getUserProfile(accessToken: tokenString) { result in switch result { case .success(let profile): // 반환 예시: ["name": "홍길동", "email": "user@naver.com", "nickname": "길동이", ...] for (key, value) in profile { print("\(key): \(value)") } case .failure(let error): print("프로필 조회 실패: \(error.errorDescription ?? "")") } } ``` -------------------------------- ### Get Current Token — NidOAuth.shared.accessToken / refreshToken Source: https://context7.com/naver/naveridlogin-sdk-ios-swift/llms.txt Retrieves the current access and refresh tokens stored in the keychain. Returns `nil` if there's no login history or after logout. The `AccessToken` object provides `tokenString`, `expiresAt`, and `isExpired` properties. ```swift import NidThirdPartyLogin // 저장된 액세스 토큰 확인 if let accessToken = NidOAuth.shared.accessToken { print("토큰 값: \(accessToken.tokenString)") print("만료 시각: \(accessToken.expiresAt)") print("만료 여부: \(accessToken.isExpired)") } else { print("저장된 액세스 토큰 없음 (로그인 필요)") } // 저장된 리프레시 토큰 확인 if let refreshToken = NidOAuth.shared.refreshToken { print("리프레시 토큰: \(refreshToken.tokenString)") } else { print("저장된 리프레시 토큰 없음") } ``` -------------------------------- ### Clone Naver ID Login SDK Repository Source: https://github.com/naver/naveridlogin-sdk-ios-swift/blob/main/README.md Clone the Git repository to access the SDK and sample projects. This command downloads the entire project history and files to your local machine. ```shell $ git clone https://github.com/naver/naveridlogin-sdk-ios-swift ``` -------------------------------- ### Add Swift Package Manager Repository Source: https://github.com/naver/naveridlogin-sdk-ios-swift/blob/main/README.md Add the Naver ID Login SDK repository URL to your Xcode project via File > Add Package dependencies. This is the primary method for integrating the SDK. ```text https://github.com/naver/naveridlogin-sdk-ios-swift ``` -------------------------------- ### Apache License 2.0 Source: https://github.com/naver/naveridlogin-sdk-ios-swift/blob/main/README.md This is the full text of the Apache License, Version 2.0, under which the Naver ID Login SDK for iOS Swift is distributed. It outlines the terms for use, modification, and distribution of the software. ```text Naver ID Login SDK for iOS Swift Copyright (c) 2025-present NAVER Corp. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ``` -------------------------------- ### Handle URL Callback — NidOAuth.shared.handleURL Source: https://context7.com/naver/naveridlogin-sdk-ios-swift/llms.txt Passes the callback URL from the Naver app back to the SDK. This should be called in `SceneDelegate.scene(_:openURLContexts:)` or `AppDelegate.application(_:open:options:)`. Returns `true` if the SDK handles the URL. ```swift // SceneDelegate.swift import NidThirdPartyLogin class SceneDelegate: UIResponder, UIWindowSceneDelegate { func scene(_ scene: UIScene, openURLContexts URLContexts: Set) { guard let url = URLContexts.first?.url else { return } let handled = NidOAuth.shared.handleURL(url) if !handled { // SDK가 처리하지 않은 URL에 대한 추가 처리 } } } // AppDelegate 방식 (SceneDelegate 미사용 프로젝트) func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool { return NidOAuth.shared.handleURL(url) } ``` -------------------------------- ### URL 콜백 처리 — NidOAuth.shared.handleURL(_:) Source: https://context7.com/naver/naveridlogin-sdk-ios-swift/llms.txt Handles callback URLs from the Naver app. This should be called in `SceneDelegate.scene(_:openURLContexts:)` or `AppDelegate.application(_:open:options:)` when using the Naver app login method. ```APIDOC ## URL 콜백 처리 — `NidOAuth.shared.handleURL(_:)` ### Description Handles callback URLs from the Naver app. This should be called in `SceneDelegate.scene(_:openURLContexts:)` or `AppDelegate.application(_:open:options:)` when using the Naver app login method. Returns `true` if the SDK handles the URL. ### Method `handleURL(_ url: URL) -> Bool` ### Parameters - **url** (URL) - Required - The callback URL received by the application. ### Response - **Bool** - Returns `true` if the SDK successfully handled the URL, `false` otherwise. ### Request Example ```swift // SceneDelegate.swift import NidThirdPartyLogin class SceneDelegate: UIResponder, UIWindowSceneDelegate { func scene(_ scene: UIScene, openURLContexts URLContexts: Set) { guard let url = URLContexts.first?.url else { return } let handled = NidOAuth.shared.handleURL(url) if !handled { // SDK가 처리하지 않은 URL에 대한 추가 처리 } } } // AppDelegate 방식 (SceneDelegate 미사용 프로젝트) func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool { return NidOAuth.shared.handleURL(url) } ``` ``` -------------------------------- ### 로그인 요청 — NidOAuth.shared.requestLogin(callback:) Source: https://context7.com/naver/naveridlogin-sdk-ios-swift/llms.txt Initiates the Naver login flow. The result is returned via a callback with a `Result` type. On success, `LoginResult` contains `AccessToken` and `RefreshToken`. ```APIDOC ## 로그인 요청 — `NidOAuth.shared.requestLogin(callback:)` ### Description Initiates the Naver login flow. The result is returned via a callback with a `Result` type. On success, `LoginResult` contains `AccessToken` and `RefreshToken`. ### Method `requestLogin(callback: @escaping (Result) -> Void)` ### Parameters - **callback** ((Result) -> Void) - Required - A closure that handles the login result. ### Response #### Success Response (`LoginResult`) - **accessToken** (`AccessToken`) - The access token object. - **tokenString** (String) - The access token string. - **expiresAt** (Date) - The expiration date of the access token. - **isExpired** (Bool) - Indicates if the access token is expired. - **refreshToken** (`RefreshToken`) - The refresh token object. - **tokenString** (String) - The refresh token string. #### Failure Response (`NidError`) - **errorDescription** (String?) - A human-readable description of the error. - **description** (String) - A general description of the error. ### Request Example ```swift import NidThirdPartyLogin // 로그인 버튼 액션 등에서 호출 NidOAuth.shared.requestLogin { result in switch result { case .success(let loginResult): let accessToken = loginResult.accessToken.tokenString let expiresAt = loginResult.accessToken.expiresAt let isExpired = loginResult.accessToken.isExpired let refreshToken = loginResult.refreshToken.tokenString print("로그인 성공 — 액세스 토큰: \(accessToken)") print("만료 시각: \(expiresAt), 만료 여부: \(isExpired)") case .failure(let error): // 예: 사용자 취소 → NidError.clientError(.canceledByUser) print("로그인 실패: \(error.errorDescription ?? error.description)") } } ``` ``` -------------------------------- ### Reprompt Permissions Source: https://context7.com/naver/naveridlogin-sdk-ios-swift/llms.txt Re-prompts the user for consent to access profile items. This is useful when the app requires additional permissions after initial login. The result is returned in the same `Result` format as `requestLogin`. ```APIDOC ## Reprompt Permissions ### Description Re-prompts the user for consent to access profile items, typically when the app needs additional permissions. ### Method Signature `NidOAuth.shared.repromptPermissions(callback:)` ### Parameters - `callback` ((Result) -> Void): A closure that receives the result of the permission re-prompt. It returns a `LoginResult` on success or a `NidError` on failure. ### Response Example ```swift // Result format is identical to requestLogin: Result ``` ### Request Example ```swift import NidThirdPartyLogin NidOAuth.shared.repromptPermissions { result in switch result { case .success(let loginResult): print("권한 재동의 완료 — 새 토큰: \(loginResult.accessToken.tokenString)") case .failure(let error): print("권한 재요청 실패: \(error.errorDescription ?? "")") } } ``` ``` -------------------------------- ### Re-prompt Permissions with NidOAuth.shared.repromptPermissions Source: https://context7.com/naver/naveridlogin-sdk-ios-swift/llms.txt Asks the user to re-consent to access profile information. Use this when your app requires additional permissions after the initial login. The result format is the same as `requestLogin`. ```swift import NidThirdPartyLogin NidOAuth.shared.repromptPermissions { result in switch result { case .success(let loginResult): print("권한 재동의 완료 — 새 토큰: \(loginResult.accessToken.tokenString)") case .failure(let error): print("권한 재요청 실패: \(error.errorDescription ?? "")") } } ``` -------------------------------- ### Verify Access Token with NidOAuth.shared.verifyAccessToken Source: https://context7.com/naver/naveridlogin-sdk-ios-swift/llms.txt Verifies the validity of an access token with the server. Use this to confirm the actual token status, unlike the local `isExpired` property. Requires the token string as input. ```swift import NidThirdPartyLogin guard let tokenString = NidOAuth.shared.accessToken?.tokenString else { print("저장된 액세스 토큰이 없습니다.") return } NidOAuth.shared.verifyAccessToken(tokenString) { result in switch result { case .success(let isValid): if isValid { print("토큰이 유효합니다.") } else { print("토큰이 유효하지 않습니다. 재로그인이 필요합니다.") } case .failure(let error): // 예: 네트워크 오류 → NidError.serverError(.networkError(...)) print("검증 중 오류 발생: \(error.errorDescription ?? "")") } } ``` -------------------------------- ### Request Login — NidOAuth.shared.requestLogin Source: https://context7.com/naver/naveridlogin-sdk-ios-swift/llms.txt Initiates the Naver login flow. The result is returned via a callback as a `Result`. On success, `LoginResult` contains `AccessToken` and `RefreshToken`. ```swift import NidThirdPartyLogin // 로그인 버튼 액션 등에서 호출 NidOAuth.shared.requestLogin { result in switch result { case .success(let loginResult): let accessToken = loginResult.accessToken.tokenString let expiresAt = loginResult.accessToken.expiresAt let isExpired = loginResult.accessToken.isExpired let refreshToken = loginResult.refreshToken.tokenString print("로그인 성공 — 액세스 토큰: \(accessToken)") print("만료 시각: \(expiresAt), 만료 여부: \(isExpired)") case .failure(let error): // 예: 사용자 취소 → NidError.clientError(.canceledByUser) print("로그인 실패: \(error.errorDescription ?? error.description)") } } ``` -------------------------------- ### Verify Access Token Source: https://context7.com/naver/naveridlogin-sdk-ios-swift/llms.txt Verifies the validity of the access token with the server. Unlike the local `isExpired` property, this method checks the token status through actual server communication. It returns `true` if the token is valid and `false` otherwise. ```APIDOC ## Verify Access Token ### Description Verifies the validity of the access token with the server. ### Method Signature `NidOAuth.shared.verifyAccessToken(_:callback:)` ### Parameters - `accessToken` (String): The access token string to verify. - `callback` ((Result) -> Void): A closure that receives the verification result. ### Request Example ```swift import NidThirdPartyLogin guard let tokenString = NidOAuth.shared.accessToken?.tokenString else { print("저장된 액세스 토큰이 없습니다.") return } NidOAuth.shared.verifyAccessToken(tokenString) { result in switch result { case .success(let isValid): if isValid { print("토큰이 유효합니다.") } else { print("토큰이 유효하지 않습니다. 재로그인이 필요합니다.") } case .failure(let error): print("검증 중 오류 발생: \(error.errorDescription ?? "")") } } ``` ``` -------------------------------- ### Reauthenticate Source: https://context7.com/naver/naveridlogin-sdk-ios-swift/llms.txt Requests re-authentication from the user for enhanced security. This forces the user to re-enter credentials (like password) even if an existing session is active. The callback format is the same as `requestLogin`. ```APIDOC ## Reauthenticate ### Description Requests re-authentication from the user for security purposes, requiring them to re-enter credentials. ### Method Signature `NidOAuth.shared.reauthenticate(callback:)` ### Parameters - `callback` ((Result) -> Void): A closure that receives the re-authentication result. It returns a `LoginResult` on success or a `NidError` on failure (e.g., user cancellation). ### Response Example ```swift // Callback format is identical to requestLogin: Result ``` ### Request Example ```swift import NidThirdPartyLogin NidOAuth.shared.reauthenticate { result in switch result { case .success(let loginResult): print("재인증 성공 — 액세스 토큰: \(loginResult.accessToken.tokenString)") case .failure(let error): print("재인증 실패 또는 취소: \(error.errorDescription ?? "")") } } ``` ``` -------------------------------- ### 로그인 방식 설정 — NidOAuth.shared.setLoginBehavior(_:) Source: https://context7.com/naver/naveridlogin-sdk-ios-swift/llms.txt Sets the preferred login method using the `LoginBehavior` enum. The default is `.appPreferredWithInAppBrowserFallback`. ```APIDOC ## 로그인 방식 설정 — `NidOAuth.shared.setLoginBehavior(_:)` ### Description Sets the preferred login method using the `LoginBehavior` enum. The default is `.appPreferredWithInAppBrowserFallback`. ### Method `setLoginBehavior(_ behavior: LoginBehavior)` ### Parameters - **behavior** (`LoginBehavior`) - Required - The desired login behavior. Options are: - `.app`: Always use the Naver app for login (will error if not installed). - `.inAppBrowser`: Always use the in-app browser for login. - `.appPreferredWithInAppBrowserFallback`: Prioritize the Naver app; fall back to the in-app browser if the app is not installed (default). ### Request Example ```swift import NidThirdPartyLogin // 세 가지 LoginBehavior 옵션: // .app → 항상 네이버 앱으로 로그인 (미설치 시 오류) // .inAppBrowser → 항상 인앱 브라우저로 로그인 // .appPreferredWithInAppBrowserFallback → 앱 우선, 없으면 브라우저 (기본값) NidOAuth.shared.setLoginBehavior(.inAppBrowser) // 이후 requestLogin 호출 시 인앱 브라우저를 통해 로그인 진행 NidOAuth.shared.requestLogin { result in switch result { case .success(let loginResult): print("인앱 브라우저 로그인 성공: \(loginResult.accessToken.tokenString)") case .failure(let error): print("오류: \(error)") } } ``` ``` -------------------------------- ### Logout Source: https://context7.com/naver/naveridlogin-sdk-ios-swift/llms.txt Deletes token information stored on the client (keychain). This action only terminates the local session and does not affect server-side tokens. It is a synchronous call with no callback. ```APIDOC ## Logout ### Description Deletes token information stored on the client (keychain), terminating the local session. ### Method Signature `NidOAuth.shared.logout()` ### Behavior - Synchronous call. - No callback is provided. - `NidOAuth.shared.accessToken` and `NidOAuth.shared.refreshToken` will be `nil` after logout. ### Usage Example ```swift import NidThirdPartyLogin func logoutButtonTapped() { NidOAuth.shared.logout() print("로그아웃 완료") } ``` ``` -------------------------------- ### 현재 토큰 조회 — NidOAuth.shared.accessToken / NidOAuth.shared.refreshToken Source: https://context7.com/naver/naveridlogin-sdk-ios-swift/llms.txt Retrieves the currently stored access and refresh tokens from the keychain. Returns `nil` if no login history exists or after logout. ```APIDOC ## 현재 토큰 조회 — `NidOAuth.shared.accessToken` / `NidOAuth.shared.refreshToken` ### Description Retrieves the currently stored access and refresh tokens from the keychain. Returns `nil` if no login history exists or after logout. The `AccessToken` object provides `tokenString`, `expiresAt`, and `isExpired` properties. ### Properties - **accessToken** (`AccessToken?`) - The current access token object, or `nil`. - **tokenString** (String) - The access token string. - **expiresAt** (Date) - The expiration date of the access token. - **isExpired** (Bool) - Indicates if the access token is expired. - **refreshToken** (`RefreshToken?`) - The current refresh token object, or `nil`. - **tokenString** (String) - The refresh token string. ### Request Example ```swift import NidThirdPartyLogin // 저장된 액세스 토큰 확인 if let accessToken = NidOAuth.shared.accessToken { print("토큰 값: \(accessToken.tokenString)") print("만료 시각: \(accessToken.expiresAt)") print("만료 여부: \(accessToken.isExpired)") } else { print("저장된 액세스 토큰 없음 (로그인 필요)") } // 저장된 리프레시 토큰 확인 if let refreshToken = NidOAuth.shared.refreshToken { print("리프레시 토큰: \(refreshToken.tokenString)") } else { print("저장된 리프레시 토큰 없음") } ``` ``` -------------------------------- ### Re-authenticate User with NidOAuth.shared.reauthenticate Source: https://context7.com/naver/naveridlogin-sdk-ios-swift/llms.txt Prompts the user to re-authenticate for enhanced security, even if an active session exists. This forces the user to re-enter credentials like passwords. The callback format matches `requestLogin`. ```swift import NidThirdPartyLogin NidOAuth.shared.reauthenticate { result in switch result { case .success(let loginResult): print("재인증 성공 — 액세스 토큰: \(loginResult.accessToken.tokenString)") case .failure(let error): // 예: 사용자 취소 → NidError.clientError(.canceledByUser) print("재인증 실패 또는 취소: \(error.errorDescription ?? "")") } } ``` -------------------------------- ### Logout with NidOAuth.shared.logout Source: https://context7.com/naver/naveridlogin-sdk-ios-swift/llms.txt Deletes token information stored locally (keychain) to end the client-side session. This does not affect server-side tokens. It's a synchronous call with no callback. ```swift import NidThirdPartyLogin // 로그아웃 버튼 액션 func logoutButtonTapped() { NidOAuth.shared.logout() // 로컬 토큰이 삭제됨 // NidOAuth.shared.accessToken → nil // NidOAuth.shared.refreshToken → nil print("로그아웃 완료") } ``` -------------------------------- ### Disconnect Source: https://context7.com/naver/naveridlogin-sdk-ios-swift/llms.txt Completely disconnects the Naver service by deleting all token information stored on both the client and the server. This operation is considered successful even if called when not logged in. Errors are delivered via a callback. ```APIDOC ## Disconnect ### Description Completely disconnects the Naver service by deleting all token information from the client and server. ### Method Signature `NidOAuth.shared.disconnect(callback:)` ### Parameters - `callback` ((Result) -> Void): A closure that receives the disconnection result. Success is indicated by `.success`, and failure by `.failure` with a `NidError`. ### Behavior - Deletes tokens from both client and server. - Considered successful even if not logged in. ### Request Example ```swift import NidThirdPartyLogin NidOAuth.shared.disconnect { result in switch result { case .success: print("연동 해제 완료 — 서버 및 클라이언트 토큰 모두 삭제됨") case .failure(let error): print("연동 해제 실패: \(error.errorDescription ?? "")") } } ``` ``` -------------------------------- ### Disconnect Service with NidOAuth.shared.disconnect Source: https://context7.com/naver/naveridlogin-sdk-ios-swift/llms.txt Completely disconnects the service by deleting token information from both the client and server. This operation is considered successful even if not logged in. Errors are returned via the callback. ```swift import NidThirdPartyLogin NidOAuth.shared.disconnect { result in switch result { case .success: print("연동 해제 완료 — 서버 및 클라이언트 토큰 모두 삭제됨") case .failure(let error): // 예: 서버 오류 → NidError.serverError(.networkError(...)) print("연동 해제 실패: \(error.errorDescription ?? "")") } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.