celtic-project / LTI-PHP

PHP class library for building LTI integrations
GNU Lesser General Public License v3.0
47 stars 37 forks source link

Error while getting Message Params #66

Closed onebonsai closed 8 months ago

onebonsai commented 10 months ago

A client wants to connect their system through LTI 1.3 to ours. Our tool uses CeLTIc to connect to it. The client has the platform.

When the client wants to run our tool, we get a fatal error:

ceLTIc\LTI\Tool::getMessageParameters(): Return value must be of type array, null returned App \ Http \ Controllers \ LMS \ LtiTool : 152 createDeploymentIdFromExistingPlatform

--> $messageParms = collect($this->getMessageParameters());

$this->getMessageParameters() is null.

When I dig deeper, I see that at just before this error pops, the following parameters are being transmitted:

dd($this->getRawParameters()); array:3 [▼ // vendor/celtic/lti/src/Tool.php:417 "error" => "login_required" "state" => "0Y...IV" "session_state" => "Bkd128ZrUA1Pa0h...bBw.777814299A2187C8BE5BC7CF707AA248" ]

if ($this->messageParameters == null) { dd($this); }

App\Http\Controllers\LMS\LtiTool {#2531 ▼ // vendor/celtic/lti/src/Tool.php:435 +platform: null +returnUrl: null +userResult: null +resourceLink: null +context: null +defaultEmail: "" +allowSharing: false +message: null +baseUrl: null +vendor: ceLTIc\LTI\Profile\Item {#2532 ▶} +product: ceLTIc\LTI\Profile\Item {#2533 ▶} +requiredServices: [] +optionalServices: [] +resourceHandlers: [] +messageUrl: null +initiateLoginUrl: null +redirectionUris: null

redirectUrl: null

mediaTypes: null

contentTypes: null

fileTypes: null

documentTargets: null

output: null

errorOutput: null

-constraints: [] +ok: false +ltiVersion: null +name: null +secret: null +signatureMethod: "RS256" +encryptionMethod: null +dataConnector: ceLTIc\LTI\DataConnector\DataConnector_pdo_mysql {#2528 ▶} +rsaKey: """ -----BEGIN RSA PRIVATE KEY----- -----END RSA PRIVATE KEY----- """ +requiredScopes: array:4 [▶] +kid: "key-1" +jku: null +reason: "login_required" +details: [] +warnings: [] +debugMode: false +enabled: false +enableFrom: null +enableUntil: null +lastAccess: null +created: null +updated: null +idScope: ceLTIc\LTI\Enum\IdScope {#2530 ▶}

jwt: null

rawParameters: array:3 [▶]

messageParameters: null

-id: null -key: null -settings: [] -settingsChanged: false

launchType: ""

}

I do not fully understand where we are and why this specific information is being sent. In any case, CeLTIc goes bananas at that point :-)

To be honest, I don't know if the client implemented LTI 1.3 correctly, but they claim to be connected to other Tool providers through LTI 1.3 already. I do not have access to their code base.

Note: we already have a working system on Moodle through LTI 1.3. This makes me suspect something on the client side if going wrong, but that is difficult from this point to prove...

Any clue as to what is going wrong here?

spvickers commented 10 months ago

Thanks for reporting this issue. The PHP error is being caused by the getMessageParameters returning a null value but the method has only been declared as returning an array. I will commit a change for this, but in the meantime you can just change the return type for this method in Tool.php from "array" to "?array".

As for the cause of the null value, it looks like your LTI platform is returning a "login_required" error which is presumably its response to the authentication request sent to it by your tool. It is possible that this could be caused by a cookie issue; try opening the tool in a new window if you're not already doing so. Otherwise you could check the log files for the LTI platform for clues, or inspect the exchange of requests which is occurring during this workflow; check especially the initiate login request being sent by the LTI platform to start the connection process. Post a copy here if you are not able to identify the error, preferably with a copy of the authentication request sent by the LTI tool in response.

onebonsai commented 10 months ago

Thanks for your response! I have asked the external party (platform) if they can check for more details in the logs about the "login_required" issue. I will come back with more details once I have them. Maybe it can help mitigate future issues.

etraininteractive commented 9 months ago

Hi @spvickers this issue is also present here:

PHP Fatal error: Uncaught TypeError: ceLTIc\LTI\Tool::sendRegistration(): Return value must be of type array, null returned in /var/www/html/vendor/celtic/lti/src/Tool.php:957

https://github.com/celtic-project/LTI-PHP/blob/94a13eafa9df77aab61cadf153786dcb65d8f6e3/src/Tool.php#L954C34-L954C34

spvickers commented 9 months ago

Thanks for reporting this being present in the sendRegistration method - fix committed. Are you still planning to get back to me about the login_required issue, or can I now close this issue?

spvickers commented 8 months ago

@onebonsai please open a new issue if you still need assistance with the login_required matter.