Created
December 2, 2021 23:24
-
-
Save PaulTR/721ce53e33c77ecb5aa6e5e4f69edfef 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 makeApiCall() { | |
authState.performActionWithFreshTokens(authorizationService, | |
object: AuthState.AuthStateAction { | |
override fun execute(accessToken: String?, idToken: String?, ex: AuthorizationException?) { | |
GlobalScope.launch { | |
async(Dispatchers.IO) { | |
val client = OkHttpClient() | |
val request = Request.Builder() | |
.url(Constants.URL_API_CALL) | |
.addHeader("Authorization", "Bearer " + authState.accessToken) | |
.build() | |
try { | |
val response = client.newCall(request).execute() | |
val jsonBody = response.body?.string() ?: "" | |
Log.i(LOG_TAG, JSONObject(jsonBody).toString()) | |
} catch (e: Exception) { } | |
} | |
} | |
} | |
} | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment