"Access control exception" error from Python Get Request

"Access control exception" error from Python Get Request

by subarna chowdhury soma -
Number of replies: 0

I have a moodle site up and running in my local. I have an admin account with all the privileges and also completed all the set ups [e.g enabling web service, protocol etc]. Finally I have generated a token and trying  to use function '

core_course_get_courses' by a simple get request from python. But I am continuously getting "Access control exception". Is there any suggested solution or I am missing something? 
#Python Code

import requests

token = 'XXXXXXXXXXXXXXXXXXX'
function = 'core_course_get_courses'

url = 'http://mymoodlesite/webservice/rest/server.php?wstoken={0}&wsfunction={1}'.format(token,function)

response =requests.get(url)
print(response.status_code)
print(response.json())
Error output: 

<?xml version="1.0" encoding="UTF-8" ?>

<EXCEPTION class="webservice_access_exception">

    <ERRORCODE>accessexception</ERRORCODE>

    <MESSAGE>Access control exception</MESSAGE>

</EXCEPTION>

Average of ratings: -