Skip to content

Instantly share code, notes, and snippets.

@johngoren
Created August 18, 2020 14:02
Show Gist options
  • Save johngoren/70e9bdd0a9a5c5d5e115e69c115cc1d8 to your computer and use it in GitHub Desktop.
Save johngoren/70e9bdd0a9a5c5d5e115e69c115cc1d8 to your computer and use it in GitHub Desktop.
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