Skip to content

Commit

Permalink
Merge pull request #2319 from drgrice1/bugfix/lti-1.3-job-queue-submi…
Browse files Browse the repository at this point in the history
…t-grade

Fix an issue that can cause LTI 1.3 grade passback to fail when called from the job queue.
  • Loading branch information
Alex-Jordan authored Mar 5, 2024
2 parents 3f6ac13 + c10f3c7 commit afc36ae
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/WeBWorK/Authen/LTIAdvantage/SubmitGrade.pm
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,17 @@ async sub get_access_token ($self) {
my $c = $self->{c};
my $ce = $c->{ce};
my $db = $c->{db};
$c = $c->{app} if $self->{post_processing_mode};

my $current_token = decode_json($db->getSettingValue('LTIAdvantageAccessToken') // '{}');

# If the token is still valid (and not about to expire) then it can still be used.
# If the token has not expired and is not about to expire, then it can still be used.
if (%$current_token && $current_token->{timestamp} + $current_token->{expires_in} > time + 60) {
$self->warning('Using current access token from database.');
return $current_token;
}

# The token is about to expire, so get a new one.
# The token is expired or about to, so get a new one.

my ($private_key, $err) = get_site_key($ce, 1);
if (!$private_key) {
Expand All @@ -150,7 +151,7 @@ async sub get_access_token ($self) {
);
};
if ($@) {
$self->warning("Error encoding JWT: $@") if $@;
$self->warning("Error encoding JWT: $@");
return;
}

Expand Down

0 comments on commit afc36ae

Please sign in to comment.