dominik-th / matomo-plugin-LoginOIDC

external authentication services for matomo
https://plugins.matomo.org/LoginOIDC/
GNU General Public License v3.0
41 stars 29 forks source link

Missing form parameter: grant_type #2

Closed ldelouw closed 5 years ago

ldelouw commented 5 years ago

Hi,

I'm using Keycloak as OpenID provider. It seems not to be working as expected. The error message reads: "Unexpected response from OAuth service".

I've inserted some debug stuff in Controller.php and the (redacted) output is the following:

print_r($dataString);

{"client_id":"piwik","client_secret":"asdfasdfasdf","code":"asdf-asdf-asdf","redirect_uri":"https:\/\/app.example.com\/piwik\/index.php?module=LoginOIDC&action=callback&provider=oidc","grant_type":"authorization_code","state":"0123"}

print_r (curl_getinfo($curl)); Array ( [url] => https://keycloak.example.com/auth/realms/master/protocol/openid-connect/token [content_type] => application/json [http_code] => 400 [header_size] => 248 [request_size] => 967 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0.020748 [namelookup_time] => 0.008359 [connect_time] => 0.008843 [pretransfer_time] => 0.018113 [size_upload] => 763 [size_download] => 84 [speed_download] => 4200 [speed_upload] => 38150 [download_content_length] => 84 [upload_content_length] => 763 [starttransfer_time] => 0.020673 [redirect_time] => 0 [redirect_url] => [primary_ip] => keycloak-ipaddress [certinfo] => Array ( ) [primary_port] => 443 [local_ip] => applicationserver-ipaddress [local_port] => 43032 )

print $response; {"error":"invalid_request","error_description":"Missing form parameter: grant_type"}

Any hint what went wrong?

Thanks,

Luc

dominik-th commented 5 years ago

Hi Luc,

apparently the access token request should not be json encoded (OAuth Spec) and the other clients I tested with were just a little more forgiving. Anyways, fixed in 0.1.2 :)

ldelouw commented 5 years ago

Tanks a lot, works perfectly now :-)