I am using the Google Civic Information for a Django app that will take user input and redirect the user according to whether or not he/she lives in Texas House District 51. I keep receiving the same error although I'm not even close to exceeding my daily quota (four requests, four errors). Do you have any insight into what is causing the error and how it might be remedied? I receive the same error regardless of whether I use Django's development server or Heroku. I think the problem might have to do with my HTTP request's headers, although I'm not sure how to fix it. I'm using an API key to authenticate the request and don't believe I should have to use Oauth for this use case.
Many thanks,
Alejandro Peña
{'error': {'code': 403,
'errors': [{'domain': 'usageLimits',
'extendedHelp': '
https://code.google.com/apis/console',
'message': 'Daily Limit for Unauthenticated Use '
'Exceeded. Continued use requires signup.',
'reason': 'dailyLimitExceededUnreg'}],
'message': 'Daily Limit for Unauthenticated Use Exceeded. Continued '
'use requires signup.'}}
def process_form(request):
if request.method == 'POST':
# create a form instance and populate it with data from the request:
form = AddressForm(request.POST)
# check whether it's valid:
if form.is_valid():
# process the data in form.cleaned_data as required
chunk = []
raw_address = form.cleaned_data['your_address']
for x in raw_address:
if x != " ":
chunk.append(x)
elif x == " ":
chunk.append("+")
else:
pass
key = "<your key>"
url = "
https://www.googleapis.com/civicinfo/v2/representatives?address=" + "".join(
chunk) + "&includeOffices=true&key=" + key
# Need to add error handling
contents = requests.get(url)
data = contents.json()
lowerHouse = data['offices'][7]['name']
if lowerHouse == "TX State House District 51":
return redirect('welcome/')
else:
return HttpResponse('Sorry, you do not live in HD51!')