Is the link in Moodle an external learning tool link as opposed to a plain old link?
That would also explain what you experience.
Follow the steps here to plan external tool links:
https://webwork.maa.org/wiki/LTI-Advanced_Authentication#Moodle_2It also could be that the LTI setting are not configured correctly. In course.conf, add:
$debug_lti_parameters = 1;
Then follow the link from Moodle and you should see a report of LTI parameters and it may reveal what is not configured right.