Forums | Mahara Community

Mahara/Moodle integration /
Maharaws and Moodle integration generic error


A Singh's profile picture
Posts: 13

24 March 2023, 8:25

I integrated mahara with moodle after following the steps available at : https://github.com/catalyst/moodle-assignsubmission_maharaws

However, i get a generic error :

error/Error when connecting to Mahara web services. Access control exception : Invalid token selected or none supplied Check that URL and OAuth credentials are correct and that there is a valid SSL certificate if HTTPS is used. Also check that the correct functions are assigned to the OAuth access.

After extensive testing and going through several forum posts it was revealed that we can get this error for several different reasons however in our case it seems to because of proxy or load balancing server modifying the headers

Example 1 : Moodle 3.11.11 and mahara 22.10.0 which are behind a proxy or a load balancing server

These headers are being received by mahara, printed from monportfolio/webservice/rest/server.php by modfying the part of code repsonsible for guessing the authmethod 

// make a guess as to what the auth method is - this gets refined later
if (param_variable('wsusername', null) || param_variable('wspassword', null)) {
    $authmethod = WEBSERVICE_AUTHMETHOD_USERNAME;
}
else  {    
    
   foreach ($headers as $header => $value)

               {
                 echo "Header $counter start =>  $header: $value <br />\n <= Header $counter end";
                 $counter++;
                }


    $authmethod = WEBSERVICE_AUTHMETHOD_PERMANENT_TOKEN;
}



Header 1 start => Connection: close <= Header 1 end

Header 2 start => Content-Length: 273 <= Header 2 end

Header 3 start => X-Forwarded-Server: www.domain.ca <= Header 3 end

Header 4 start => X-Forwarded-Host: www.domain.ca <= Header 4 end

Header 5 start => X-Proxy-Request-Uri: https://www.domain.ca/monportfolio/webservice/rest/server.php <= Header 5 end

Header 6 start => X-Proxy-Secured: yes <= Header 6 end

Header 7 start => X-Forwarded-Proto: https <= Header 7 end

Header 8 start => X-Client-Ip: 10.32.XX.XX <= Header 8 end

Header 9 start => X-Forwarded-For: 10.32.XX.XX <= Header 9 end

Header 10 start => Content-Type: multipart/form-data; boundary=------------------------7bc3fbe3aaf51552 <= Header 10 end

Header 11 start => User-Agent: MoodleBot/3.11 (+https://www.domain.ca/moodle-3.11.11) <= Header 11 end

Header 12 start => Accept-Encoding: deflate, gzip, br <= Header 12 end

Header 13 start => Accept: */* <= Header 13 end

Header 14 start => Host: server-dev01.ti.domain.ca <= Header 14 end

Example 2 :  moodle-3.11.11 and mahara 22.10.0 on localhost (Working case)

Header 2 start => Accept: */* <= Header 2 end

Header 3 start => Accept-Encoding: deflate, gzip <= Header 3 end

Header 4 start => Authorization: OAuth alt="json", oauth_consumer_key="CorrectKeyxxxxx", oauth_nonce="correctSecretxxxxx", oauth_signature="CorrectSignature", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1673987902", oauth_token="", oauth_version="1.0", wsfunction="mahara_user_get_extended_context" <= Header 4 end

Header 5 start => User-Agent: MoodleBot/3.11 (+http://localhost/moodle-3.11.11) <= Header 5 end

Header 6 start => Content-Length: 273 <= Header 6 end

Header 7 start => Content-Type: multipart/form-data; boundary=------------------------b9a1050e9dfc1222 <= Header 7 end

Already tried:

Verfying the blocked curl hosts on moodle
Turning on assignubmission option for teachers

My original assumption was that the load balancer was somehow modifying the headers but upon further investigation it was revelaed that it isn't affecting the headers.

Any suggestions, available advance settings or solutions are welcomed. Thanks in advance

Kristina Hoeppner's profile picture
Posts: 4731

28 March 2023, 7:51

Hi,

Could you please check this forum thread and see if that provides some answers for you?

Thanks

Kristina

A Singh's profile picture
Posts: 13

28 March 2023, 9:01

Unfortunately no. I already tried turning on that option. This particular error is very generic and can pop up for a variety of reasons which aren't related at all. The only common result is that the mahara isn't receiving the correct information that in result calls the common error function.

In our case (and probably for many others), it seems to be mutation of the headers at some point, most probably at point where mahara receives the information from moodle. The request does reach mahara,. However, due to malformed header values which doesn't contain the required secret, key, method and other values, mahara cannot determine the correct function and thus return this generic error. 

LTI-integration sends similar data using separate functions on moodle side to a different class in mahara and It works as expected.

 

02 August 2023, 22:45

@A Singh,

Did you ever get this Mahara submission in Moodle assignment to work? We are running into the same problems.

4 results