AppAuth-Android icon indicating copy to clipboard operation
AppAuth-Android copied to clipboard

Add methods to request access token synchronous

Open TizioIncognito opened this issue 5 years ago • 1 comments

TizioIncognito avatar Dec 03 '20 08:12 TizioIncognito

in kotlin you can easily do it with extension and suspendable method:

internal suspend fun AuthState.performActionWithFreshTokens(service: AuthorizationService): String =
        suspendCancellableCoroutine { cont ->
            performActionWithFreshTokens(service) { accessToken, idToken, ex ->
                if(accessToken != null) {
                    cont.resume(accessToken)
                } else {
                    cont.cancel(ex)
                }
            }
        }

filipkowicz avatar Mar 05 '21 14:03 filipkowicz