-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Token expiration issue #95
Comments
When I adjust the code to accommodate with a 5 sec difference in token, things go further, but do not yet work fully. I get this as result:
This might again be a Moodle issue. In this case, the token is still used even if the time is slightly off. This might also be a violation of the LTI1.3 standard... Maybe this gives you an idea? |
This does indeed sound like a Moodle issue, or perhaps just an error with the clock on either the Moodle or tool server. Your logs show that you are still getting the "Unable to obtain an access token for scope: https://purl.imsglobal.org/spec/lti-ags/scope/score" (as per issue #93), so it might also be just a tool configuration error in Moodle. If you are finding that the error is just a few seconds, then my suspicion is that the clock on one of the servers has not been correctly adjusted when daylight savings time ended/started. Tokens are issued for an hour and so a few seconds difference in clock times should not be a problem. |
Your logs show the sending of a token with a value of "96adb41e39e0e"; are you able to share a copy of a request and response showing a token being issued by Moodle? In addition, your comments suggest that you are trying to use the Score service, but your logs show a request to the Basic Outcomes service; if this is the service you are wanting to use then you should be requesting the scope associated with this service when requesting an access token. |
Hi,
we have had a conversation about the issue to connect to Moodle. After much digging, we might have found a potential cause of the problem.
The root of the problem seems to be that sometimes the token communicated back from Moodle has not exactly the same time stamp as the current time at the server of the tool. This results in an error when sending back the score to Moodle.
This is a very subtle issue, as it does not always happen (however it does often happen) and will also depend on where the two servers are located. If the platform and tool are on the same server, the issue does not occur. If they are in the same datacenter, it does not occur most of the times. If they are in the same country, it might occur. If they are on the other side of the planet, often it occurs.
This is the function in AccessToken.php that is causing the issue. If $this->expires <= time() it returns an error. So if the times differ even with 1 second, it will fail.
This is a detailed log, showing the problem:
I added a lot of extra logging to show. The line "Token expires" shows the small difference (1 second). This is between a server in Frankfurt and Sydney.
The function is called through
I think to solve this issue, the code should account for small deviations, such as 1-5 seconds. Or maybe you have a better way to solve this?
The text was updated successfully, but these errors were encountered: