Morgan Allen Morgan Allen - 5 months ago 59
Python Question

Using Flask to access Google's API

I'm trying to create a Flask app that talks to Google's API. However, I keep getting this error:

Traceback (most recent call last):
File "", line 16, in <module>
File "/Library/Python/2.7/site-packages/flask/", line 1013, in decorator
self.add_url_rule(rule, endpoint, f, **options)
File "/Library/Python/2.7/site-packages/flask/", line 62, in wrapper_func
return f(self, *args, **kwargs)
File "/Library/Python/2.7/site-packages/flask/", line 976, in add_url_rule
rule = self.url_rule_class(rule, methods=methods, **options)
File "/Library/Python/2.7/site-packages/werkzeug/", line 599, in __init__
raise ValueError('urls must start with a leading slash')
ValueError: urls must start with a leading slash

I went through the Flask tutorial and the "Using OAuth 2.0 for Web Services" on Google's website. I'm not quite sure what I'm doing wrong, and I'm not quite sure what the error is telling me. It looks like it has something to do with with Flask? Here is my code:

from flask import Flask
from oauth2client import client

app = Flask(__name__)

def hello():
return "Hello world!"

def google_api():
flow = client.flow_from_clientsecrets(

def redir():
return "Authenticated"

if __name__ == '__main__':
app.debug = True

What am I doing wrong? How can I fix it?


I think you are missing the leading slash from your google api route.


Have you tried updating to


Hope that helps