WeBWorK Main Forum

WW v2.19 LTI 1.3 - Canvas Integration Trouble

WW v2.19 LTI 1.3 - Canvas Integration Trouble

by Sean Beatty -
Number of replies: 6

Hi,

I have v2.19 running on RHEL8 with apache as a proxy. During the attempt to integrate with Canvas using the content selection feature, I ran into an issue with MOJO:UserAgent in two places where it is used. The issue I ran into was a connect_timeout. I was able to get around this by setting the proxy for the UserAgent in both /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/LTIAdvantage.pm and /opt/webwork/webwork2/lib/WeBWorK/Authen/LTIAdvantage/SubmitGrade.pm. 

It seems that the authentication process gets though initial login and launch ok but when it gets to content selection I receive the message:

WeBWorK::Authen::LTIAdvantage::request_has_data_for_this_verification_module: LTIAdvantage returning that it has insufficent data

In addition, I receive the message:

WeBWorK::Authen::LTIAdvantage::SubmitGrade::warning: Failed to obtain access token from LMS:Bad Request

I would be happy to share any info from my webwork2 or debug logs if it is needed.


In reply to Sean Beatty

Re: WW v2.19 LTI 1.3 - Canvas Integration Trouble

by Glenn Rice -

What exactly do you mean by "setting the proxy for the UserAgent"?

Do you have "proxy: 1" set in the hypnotoad section of conf/webwork2.mojolicious.yml?  Also, are you using the default conf/webwork2.apache2.4.conf file?

In reply to Glenn Rice

Re: WW v2.19 LTI 1.3 - Canvas Integration Trouble

by Sean Beatty -

Hi Glenn.

Yes, I have proxy: 1 in the hypnotoad section of conf/webwork2.mojolicious.yml and I am using the default conf/webwork2.apache2.4.conf file.

After my first attempt to use the content selection through Canvas I received the following message: Connect timeout at opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/LTIAdvantage.pm line 326. 

I found some info about using MOJO:UserAgent that suggested that I try the following:

# Get public keyset from the LMS.

        my $ua  = Mojo::UserAgent->new;

        $ua->proxy->https('http://xa-proxy.utsarr.net:80');

        my $response = $ua->get($ce->{LTI}{v1p3}{PublicKeysetURL})->result;

        unless ($response->is_success) {

               $c->stash->{LTIAuthenError} = 'Failed to obtain public key from LMS: ' . $response->message;


        #my $response = Mojo::UserAgent->new->get($ce->{LTI}{v1p3}{PublicKeysetURL})->result;

        #unless ($response->is_success) {

        #       $c->stash->{LTIAuthenError} = 'Failed to obtain public key from LMS: ' . $response->message;

                return;

        }

This got me past the connect_timeout error and allowed me to obtain the context_id. After entering the context id in a course, I was able to see the homework sets using the Canvas external tool. When I select a set and click the button, I get an error message from Canvas with no detailed message. In the debug log, I see the same connect timeout but this time coming from SubmitGrade.pm. I tried adding the lines 

        my $ua  = Mojo::UserAgent->new;

        $ua->proxy->https('http://xa-proxy.utsarr.net:80');

but for the post_p that occurs there. After that, I do not receive the connect_timeout but instead receive in both the debug.log and webwork2.log a message that says:

WeBWorK::Authen::LTIAdvantage::SubmitGrade::warning: Failed to obtain access token from the LMS.

I have attached a text file with the output from my debug log.

Thanks!


In reply to Sean Beatty

Re: WW v2.19 LTI 1.3 - Canvas Integration Trouble

by Glenn Rice -

Another thing to check is that you have all of the necessary apache2 modules enabled.  The proxy, proxy_http, and headers modules are needed.

Wait, I just noticed that you are setting the proxy to use http (not https) and port 80.  Are you not using SSL?  If you are not, then you should not be using the default conf/webwork2.apache2.4.conf file as is.  You need to change the line

    RequestHeader set X-Forwarded-Proto "https"

to

    RequestHeader set X-Forwarded-Proto "http"

You do not need to add the proxy to the UserAgent calls if everything is configured correctly.  I am running webwork2 proxied via apache2 as well, and am also LMS grade passback to Canvas (although with LTI 1.1 at this point, but that also uses the Mojo::UserAgent), and have not needed to add the proxy call as you are doing.

In reply to Glenn Rice

Re: WW v2.19 LTI 1.3 - Canvas Integration Trouble

by Sean Beatty -

I checked the modules that are installed an each of proxy, proxy_http, and headers are there.

We are using SSL. I tried a bunch of different combinations when setting that $ua->proxy but only 

$ua->proxy->https('http://xa-proxy.utsarr.net:80'); got me to the context_id screen. To be honest, I do not know much about mojolicious beyond what I have read in the last week or so.

I am not sure where to go next but I really appreciate the help.

In reply to Sean Beatty

Re: WW v2.19 LTI 1.3 - Canvas Integration Trouble

by Danny Glin -

Just to clarify: does your WeBWorK server require a proxy to connect to the internet?

I think there might be confusion here around two different proxies: using Apache as a reverse proxy for incoming connections, and any proxy that is used for outgoing connections.

In reply to Danny Glin

Re: WW v2.19 LTI 1.3 - Canvas Integration Trouble

by Glenn Rice -

I was wondering this as well. The URL that you are using in the proxy call does not look like the URL for your server. That looks like some external entity.