Created
August 18, 2020 14:02
-
-
Save johngoren/70e9bdd0a9a5c5d5e115e69c115cc1d8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun refreshTokensBlocking(): RefreshMyTokenResponse? { | |
Log.d("Refresher", "Entering RefreshTokensSync()") | |
val tokens = getTokens() | |
var refreshMyTokenResponse: RefreshMyTokenResponse? = null | |
runBlocking { | |
try { | |
val refreshToken = tokens?.refreshToken ?: return@runBlocking | |
val result = Online.service.refreshToken(refreshToken) | |
refreshMyTokenResponse = result | |
stashFreshRefreshInfo(refreshMyTokenResponse) | |
Log.d("Refresher", "*** Fetched a fresh token. ***") | |
} | |
catch(e: Exception) { | |
Log.d("Refresher", "*** Trouble refreshing token. ***") | |
e.message?.also { | |
Log.d("Refresher", it) | |
} | |
return@runBlocking | |
} | |
} | |
return refreshMyTokenResponse | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment