NicklasWallgren / PokemonGoAPI-PHP

Pokemon Go API PHP library
BSD 2-Clause "Simplified" License
130 stars 51 forks source link

Added VerifyChallenge logic and example to submit RECaptcha challenge token #155

Closed voxx closed 7 years ago

voxx commented 7 years ago

Really rough but works!

1) Obtain a RECaptcha challenge token using CheckChallengeExample.php and POGO-CAPTCHA bookmarklet.

2) Submit challenge token using VerifyChallengeExample.php gui form or post the token directly to this script.

3) Verify successful token submission with success=true json response.

NOTE: submitting invalid token through this form or direct post results in a protobuf read error as the protos dont appear to correctly account for empty return value of VerifyChallengeResponse. @DrDelay should be able to shed some more light on this issue maybe.

@DrDelay helped me piece the last bits together for a rough solution and also located a file naming convention error in the upstream protos files that he's opened here.

https://github.com/NicklasWallgren/pogoprotos-php/issues/10

The POGOProtos\Networking\Requests\Messages\VerifyChallenge.php file must be renamed VerifyChallengeMessage.php in order for this patch to work.

@NicklasWallgren Can we get you to take a look at this issue and address? I realize the issue exists upstream from your fork as well, so not sure what the best path to correct this is.

voxx commented 7 years ago

Error if invalid token is submitted:

"
\nWarning:  get_resource_type() expects parameter 1 to be resource, null given in /private/var/www/vhosts/pokemongoapi-php-voxx/wwwroot/vendor/nicklasw/pogoprotos-php/src/protocolbuffers.inc.php on line 54
\n
\nFatal error:  Uncaught InvalidArgumentException: fp must be a string or file resource in /private/var/www/vhosts/pokemongoapi-php-voxx/wwwroot/vendor/nicklasw/pogoprotos-php/src/protocolbuffers.inc.php:37\nStack trace:\n#0 /private/var/www/vhosts/pokemongoapi-php-voxx/wwwroot/vendor/nicklasw/pogoprotos-php/src/protocolbuffers.inc.php(54): checkArgument(false, 'fp must be a st...')\n#1 /private/var/www/vhosts/pokemongoapi-php-voxx/wwwroot/vendor/nicklasw/pogoprotos-php/src/POGOProtos/Networking/Responses/VerifyChallengeResponse.php(24): ProtobufIO::toStream(NULL, 9223372036854775807)\n#2 /private/var/www/vhosts/pokemongoapi-php-voxx/wwwroot/src/Requests/VerifyChallengeRequest.php(71): POGOProtos\\Networking\\Responses\\VerifyChallengeResponse->read(NULL)\n#3 /private/var/www/vhosts/pokemongoapi-php-voxx/wwwroot/src/Handlers/RequestHandler.php(163): NicklasW\\PkmGoApi\\Requests\\VerifyChallengeRequest->handleResponse(Object(POGOProtos\\Networking\\Envelopes\\ResponseEnvelope))\n#4 /private/var/www/vhosts/pokemongoapi-php-voxx/wwwroot/src/H in /private/var/www/vhosts/pokemongoapi-php-voxx/wwwroot/vendor/nicklasw/pogoprotos-php/src/protocolbuffers.inc.php on line 37
\n"
voxx commented 7 years ago

Successful VerifyChallenge Request

"{\"user\":\"trumswosksmund\",\"success\":true,\"token\":\"03AHJ_VuuM0qGh0Fy3GyLCU8XGVTxLiYozkhANJ1G1Mu1m_D2D5wBO99gdnlrHrCx13wstlZcKkoCF8ChxtR-Rp2g4huQAKXNB96xJ1mhB1zLxrhjhxiz5QKJxWgFMa8ZO_5nra6tAnnP6WpeMxcX-RbFYKbTnE1lzrdrf7HKCEiFQxUdudYdoP296BTW6DNKvZ4jfH8el6yiD8BsYu_noW6GjhO8HEsOz0QZlCffVKObwTud6OiuZejs8MhhB2FnaKVXXlrEACGM5Pr-9khGJsJDInIt4YI6VoD0YOV3w8PfWxIiGMU0VH9TzhfOvNHTEnog4kcGm1BILmh3FQwoJJ9UcwbkpKEb9gyDR8uw4AKBD-XP-G_w-0__laUwJb89eDM9MQhgmJloqVmEkJiSrIuhrUYMSpSZLR_mW28MUXDHtM0EPm3IuUf6atmxwu2RS-vAct4g39DBPL0TXEp5GOPFZqcf37yeomUWvs5bDqilnPcS_aanfaOvgLMC_WwjLvNkWvdCSRTDqCZciqqaMbaUGaE-dLSB8WzUkRl7bTwvzexiHcenFjXbBLqrjpOFNN1oiHc5EBAXMKyRv_Id8YvpZ3eR8n5ecABILrIKjJRWUmOiPKpO8uGb1rFcsn6TqpEfy9pXnBki7w6ap4MBBcZQLjWeAlrPwrWZPFsD2YimG56bm_0GmTJ-KoUKfVsCwEqhrMk-_kvy0hSdCsyndn-85j5W80X2gYulPvOI2IkZhg20HP7acZXiR21QHZ6jzcGr2g4gNiSoTeXVXgs75AUeM-t2EY0BN0Nlv9-NyUHZz9GOgxJP1S1Pqfm-JmOgdw-LiF69B9F78J0osf_XBJaHV8uQXI_KMatQWW780sqRHB54s_OIwWbBBWkvmKdSt123cZtu443nvp08kFiPfFzNxYSdmm2v_VhWvPJtK-vT7agBA09eqn0oJGIhgmILiAsj0CapacqQ_\"}"

screen shot 2016-10-22 at 6 29 46 am

DrDelay commented 7 years ago

The functionality the sendToken-method provides should definitely be in the API, not in an example.

After this has been changed and the autoloading problem in the protos repo has been fixed we can merge this IMO.