Created
January 14, 2021 02:13
-
-
Save Hc747/1b686927fe99b833b1d94df6d266e34c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
Flowable<Boolean> validate(String token) { | |
final Map<String, String> parameters = [secret: key(SECRET), response: token] | |
final HttpRequest<Map<String, String>> request = HttpRequest.POST(SITE_VERIFY_ENDPOINT, parameters).contentType(MediaType.APPLICATION_FORM_URLENCODED) | |
final Flowable<HttpResponse<Map<String, ?>>> exchange = http.exchange(request, Map.class) as Flowable<HttpResponse<Map<String, ?>>> | |
return exchange.map(response -> { | |
final Map<String, ?> body = response.body() | |
if (body == null) { | |
return false | |
} | |
return body.getOrDefault(KEY_SUCCESS, false) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment