![JAR search and dependency download from the Maven repository](/logo.png)
commonMain.com.huawei.hilink.c2c.integration.helper.api.CentralAccessTokenCheck.kt Maven / Gradle / Ivy
package com.huawei.hilink.c2c.integration.helper.api
/**
* Checks access token's validity early in the request processing and fills [UserInfo.authorizedUserIdOrNull] passed
* to other methods within [UserInfo] object. When it's not implemented, the value is null instead.
*
* You can either implement it, or pass a null to [HiLinkHelper]'s constructor instead. When not implemented, you'll
* need to check the AT across the other methods of [HiLinkHelper]'s interfaces.
*
* Intended purpose is to make central AT check possible, since HiLink C2C protocol doesn't accept 401 HTTP code,
* and requires a custom way of indicating that an access token is invalid. The Helper library will handle that for you,
* whenever you call onUnauthorized() callback on any of the consumers passed as the last argument in the methods of
* Helper's interfaces.
*/
public interface CentralAccessTokenCheck {
/**
* Obtains user ID by access token. The token comes from the partner's OAuth 2.0 service.
*
* This method will be called directly before other methods implemented across the Helper's interfaces,
* and the userId passed to the consumer here, will be present there as [UserInfo.authorizedUserIdOrNull].
*
* @param accessToken the AT which HiLink cloud included in header of the request that is being
* processed.
* @param consumer a callback allowing you to return the ID of the user whose [accessToken] was presented in the
* request. The id can be up to 128 characters long.
* Contains [ResultConsumer.onSuccess] and [ResultConsumer.onError] functions.
* In addition, two functions related to authorization are available: [AuthResultConsumer.onUnauthorized] and
* [AuthResultConsumer.onIllegalAccess]. Please check [AuthResultConsumer]'s documentation for a detailed description
* of the difference between the two.
*/
public fun getUserIdByToken(accessToken: String, consumer: ResultConsumer)
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy