Open Elfangor93 opened 1 year ago
Issue also available in the corresponding framework package: https://github.com/joomla-framework/oauth2/issues/19
@Elfangor93 can you help me with Joomla OAuth2 class? I don't understand how to use it. Function authenticate
needs a code
parameter in Input (Joomla\Input\Input) but when does this function fired?
I need to authorize in 3-dparty API via OAuth2 and send some data into it. Does Joomla OAuth2 class help me with this task?
Steps to reproduce the issue
Expected result
If the OAuth credentials are correct (redirecturi, clientid, clientsecret, ...) we should see two successful responses from the OAuth server. Firstly we get the token and secondly we get json data based on the requested scope.
Actual result
When the second respond comes back from the OAuth server, a PHP notice is thrown and the autenthication fails:
Notice: Undefined index: Content-Type in path/to/joomla/libraries/joomla/oauth2/client.php on line 85
System information (as much as possible)
Additional comments
The code line throwing the PHP notice is looks as follows:
if (strpos($response->headers['Content-Type'], 'application/json') === 0)
The code tries to access the value in the array ($response->headers) with key 'Content-Type' and checks therefore if the content type in the respond header is set to 'application/json'. But since the keys in http responses are case insensitive, the key could also be 'content-type' instead of 'Content-Type'. In that case the PHP notice is thrown and the autenthication fails.
The code should check the conent type of the OAuth response in a case insensitive manner, such that authentication does not fail when the content type key is responded in lower cases.
Problem still exist in newest Joomla version (4.2.3)...