NicklasWallgren / PokemonGoAPI-PHP

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

Rough Exception Handling fixes for "unexpected error" and "invalid_grant" during authentication. #158

Closed voxx closed 7 years ago

voxx commented 7 years ago

This is a rough fix for handling intermittent exceptions that can occur when attempting to authenticate.

I've added some body match checks for "unexpected error" and "invalid_grant" in ticket/token parser to throw specific error codes so they can be caught/handled by apps using the api.

Code 498 is now thrown with invalid_grant body match in TokenParser.php error response Code 503 is now thrown with unexpected error body match in TicketParser.php error response.

Preferably we'd attempt to re-auth when either of these two specific errors occur, but this at least adds the ability to catch and handle these particular error types.

I've added a rough implementation on CheckChallengeExample.php

-VoxX