Created
March 23, 2022 22:41
-
-
Save sproctor/da7ca16e206dc664e043e1d44d7d16ad 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
val code = suspendCancellableCoroutine { continuation -> | |
val server = HttpServer.create(InetSocketAddress(5789), 0) | |
server.createContext("/callback") { http -> | |
val parameters = http.requestURI.query?.let { decodeQueryString(it) } | |
val code = parameters?.get("code") ?: throw RuntimeException("Received a response with no code") | |
sendResponse(http) | |
continuation.resume(code) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment