kamermans / guzzle-oauth2-subscriber

OAuth 2.0 Client for Guzzle 4, 5, 6 and 7 with PHP 5.4 - PHP 8.0 - no more dependency hell!
MIT License
140 stars 31 forks source link

method getRawData() of grant types not interface compliant and can lead to TypeError #51

Closed PawelSuwinski closed 1 year ago

PawelSuwinski commented 1 year ago

Interface states GrantTypeInterface::getRawData(): array https://github.com/kamermans/guzzle-oauth2-subscriber/blob/b2dc192f1ce9390d3c0e399ad0610fa1fddc17ea/src/GrantType/GrantTypeInterface.php#L15-L17

but every grant type implementation ends with:

    // (...)
    return json_decode($response->getBody(), true);  // array|null|false|true`
}

It leads to TypeError if auth endpoint return empty response on bad credential (my case):

Uncaught TypeError: Argument 1 passed to kamermans\OAuth2\Token\RawTokenFactory::__invoke() must be of the type array, null given in
/var/www/html/wp-content/plugins/xtm-wpml-connector/vendor/kamermans/guzzle-oauth2-subscriber/src/Token/RawTokenFactory.php:7