Auth

public enum Auth

Authentication-related APIs. Unlike other public APIs, methods in this type don’t refresh the access token automatically. Don’t use these methods as a means of refreshing current access tokens.

  • Refreshes the access token with refreshToken.

    Note

    If the token refresh process finishes successfully, the refreshed access token will be automatically stored in the keychain for later use and you will get a .LineSDKAccessTokenDidUpdate notification. Normally, you don’t need to refresh the access token manually because any API call will attempt to refresh the access token if necessary.

    Declaration

    Swift

    public static func refreshAccessToken(
        callbackQueue queue: CallbackQueue = .currentMainOrAsync,
        completionHandler completion: @escaping (Result<AccessToken, LineSDKError>) -> Void)

    Parameters

    queue

    The callback queue that is used for completion. The default value is .currentMainOrAsync. For more information, see CallbackQueue.

    completion

    The completion closure to be invoked when the access token is refreshed.

  • Revokes the access token.

    Note

    The revoked token will be automatically removed from the keychain. If token has a nil value and the current access token does not exist, completion will be called with .success. The same applies when token has an invalid access token.

    After the access token is revoked, you cannot use it again to access the LINE Platform. You need to have the user authorize your app again to issue a new access token before accessing the LINE Platform.

    The LineSDKAccessTokenDidRemove notification is sent when the access token is removed from the device.

    Declaration

    Swift

    public static func revokeAccessToken(
        _ token: String? = nil,
        callbackQueue queue: CallbackQueue = .currentMainOrAsync,
        completionHandler completion: @escaping (Result<(), LineSDKError>) -> Void)

    Parameters

    token

    The access token to be revoked. Optional. If not specified, the current access token will be revoked.

    queue

    The callback queue that is used for completion. The default value is .currentMainOrAsync. For more information, see CallbackQueue.

    completion

    The completion closure to be invoked when the access token is revoked.

  • Revokes the refresh token and all its corresponding access tokens.

    Note

    Do not pass an access token to the refreshToken parameter. To revoke an access token, use revokeAccessToken(_:callbackQueue:completionHandler:) instead.

    The revoked token will be automatically removed from the keychain. If refreshToken has a nil value and the current refresh token does not exist, completion will be called with .success. The same applies when refreshToken has an invalid refresh token.

    This API will revoke the given refresh token and all its corresponding access tokens. Once these tokens are revoked, you can neither call an API protected by an access token or refresh the access token with the refresh token. To access the resource owner’s content, you need to ask your users to authorize your app again.

    The LineSDKAccessTokenDidRemove notification is sent when the access token is removed from the device.

    Declaration

    Swift

    public static func revokeRefreshToken(
        _ refreshToken: String? = nil,
        callbackQueue queue: CallbackQueue = .currentMainOrAsync,
        completionHandler completion: @escaping (Result<(), LineSDKError>) -> Void)

    Parameters

    refreshToken

    The refresh token to be revoked. Optional. If not specified, the current refresh token will be revoked.

    queue

    The callback queue that is used for completion. The default value is .currentMainOrAsync. For more information, see CallbackQueue.

    completion

    The completion closure to be invoked when the access token is revoked.

  • Verifies the access token.

    Note

    This method does not try to refresh the current access token when it is invalid or expired. Instead, if verification fails, it just returns the server response as an error to you.

    Declaration

    Swift

    public static func verifyAccessToken(
        _ token: String? = nil,
        callbackQueue queue: CallbackQueue = .currentMainOrAsync,
        completionHandler completion: @escaping (Result<AccessTokenVerifyResult, LineSDKError>) -> Void)

    Parameters

    token

    The access token to be verified. Optional. If not specified, the current access token will be verified.

    queue

    The callback queue that is used for completion. The default value is .currentMainOrAsync. For more information, see CallbackQueue.

    completion

    The completion closure to be invoked when the access token is verified.