API
public enum API
A utility type for calling APIs on the LINE Platform.
Note
For most API calls, using the methods in theAPI
is equivalent to using and sending an
underlying Request
object with a Session
object. However, some methods in API
provide
additional useful features such as working with the keychain and redirecting the final result
in a more reasonable way.
Using methods in API
to interact with the LINE Platform is highly recommended unless you are familiar
with and want to extend the LINE SDK to send unimplemented API requests to the LINE Platform.
-
Gets the user’s profile.
Note
The.profile
permission is required.Declaration
Swift
public static func getProfile( callbackQueue queue: CallbackQueue = .currentMainOrAsync, completionHandler completion: @escaping (Result<UserProfile, LineSDKError>) -> Void )
Parameters
queue
The callback queue that is used for
completion
. The default value is.currentMainOrAsync
. For more information, seeCallbackQueue
.completion
The completion closure to be invoked when the user’s profile is returned.
-
Gets the friendship status of the user and the LINE Official Account linked to your LINE Login channel.
Note
The.profile
permission is required.Declaration
Swift
public static func getBotFriendshipStatus( callbackQueue queue: CallbackQueue = .currentMainOrAsync, completionHandler completion: @escaping (Result<GetBotFriendshipStatusRequest.Response, LineSDKError>) -> Void )
Parameters
queue
The callback queue that is used for
completion
. The default value is.currentMainOrAsync
. For more information, seeCallbackQueue
.completion
The completion closure to be invoked when the friendship status is returned.
-
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.
See moreDeclaration
Swift
public enum Auth
-
Warning
Deprecated. UseAPI.Auth.refreshAccessToken(callbackQueue:completionHandler:)
.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 do not need to refresh the access token manually because any API call will attempt to refresh the access token if necessary.Declaration
Swift
@available(*, deprecated, renamed: "Auth.refreshAccessToken", message: "Auth-related APIs don't refresh access token automatically.\nMake sure you don't need token refreshing as a side effect, then use methods from `API.Auth` instead.") 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, seeCallbackQueue
.completion
The completion closure to be invoked when the access token is refreshed.
-
Warning
Deprecated. UseAPI.Auth.revokeAccessToken(_:callbackQueue:completionHandler:)
.Revokes the access token.
Note
The revoked token will be automatically removed from the keychain. If
token
has anil
value and the current access token does not exist,completion
will be called with.success
. The same applies whentoken
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
@available(*, deprecated, renamed: "Auth.revokeAccessToken", message: "Auth-related APIs don't refresh access tokens automatically.\nMake sure you don't need token refreshing as a side effect, then use methods from `API.Auth` instead.") 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, seeCallbackQueue
.completion
The completion closure to be invoked when the access token is revoked.
-
Warning
Deprecated. UseAPI.Auth.revokeRefreshToken(_:callbackQueue:completionHandler:)
.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, userevokeAccessToken(_:callbackQueue:completionHandler:)
instead.The revoked token will be automatically removed from the keychain. If
refreshToken
has anil
value and the current refresh token does not exist,completion
will be called with.success
. The same applies whenrefreshToken
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 will be sent when the access token is removed from the device.Declaration
Swift
@available(*, deprecated, renamed: "Auth.revokeRefreshToken", message: "Auth-related APIs don't refresh access tokens automatically.\nMake sure you don't need token refreshing as a side effect, then use methods from `API.Auth` instead.") 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, seeCallbackQueue
.completion
The completion closure to be invoked when the access token is revoked.
-
Warning
Deprecated. UseAPI.Auth.verifyAccessToken(_:callbackQueue:completionHandler:)
.Verifies the access token.
Declaration
Swift
@available(*, deprecated, renamed: "Auth.verifyAccessToken", message: "Auth-related APIs don't refresh access tokens automatically.\nMake sure you don't need token refreshing as a side effect, then use methods from `API.Auth` instead.") 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, seeCallbackQueue
.completion
The completion closure to be invoked when the access token is verified.