Search in sources :

Example 1 with VerifyChallengeResponse

use of POGOProtos.Networking.Responses.VerifyChallengeResponseOuterClass.VerifyChallengeResponse in project PokeGOAPI-Java by Grover-c13.

the class PokemonGo method verifyChallenge.

/**
	 * Verifies the current challenge with the given token.
	 *
	 * @param token the challenge response token
	 * @return if the token was valid or not
	 * @throws RequestFailedException if an exception occurred while sending requests
	 */
public boolean verifyChallenge(String token) throws RequestFailedException {
    hasChallenge = false;
    VerifyChallengeMessage message = VerifyChallengeMessage.newBuilder().setToken(token).build();
    ServerRequest request = new ServerRequest(RequestType.VERIFY_CHALLENGE, message);
    ByteString responseData = getRequestHandler().sendServerRequests(request, true);
    try {
        VerifyChallengeResponse response = VerifyChallengeResponse.parseFrom(responseData);
        hasChallenge = !response.getSuccess();
        if (!hasChallenge) {
            challengeURL = null;
            synchronized (challengeLock) {
                challengeLock.notifyAll();
            }
        }
        return response.getSuccess();
    } catch (InvalidProtocolBufferException e) {
        throw new RequestFailedException(e);
    }
}
Also used : RequestFailedException(com.pokegoapi.exceptions.request.RequestFailedException) ByteString(com.google.protobuf.ByteString) VerifyChallengeResponse(POGOProtos.Networking.Responses.VerifyChallengeResponseOuterClass.VerifyChallengeResponse) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) VerifyChallengeMessage(POGOProtos.Networking.Requests.Messages.VerifyChallengeMessageOuterClass.VerifyChallengeMessage) ServerRequest(com.pokegoapi.main.ServerRequest)

Aggregations

VerifyChallengeMessage (POGOProtos.Networking.Requests.Messages.VerifyChallengeMessageOuterClass.VerifyChallengeMessage)1 VerifyChallengeResponse (POGOProtos.Networking.Responses.VerifyChallengeResponseOuterClass.VerifyChallengeResponse)1 ByteString (com.google.protobuf.ByteString)1 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)1 RequestFailedException (com.pokegoapi.exceptions.request.RequestFailedException)1 ServerRequest (com.pokegoapi.main.ServerRequest)1