atuljain / google-api-python-client

Automatically exported from code.google.com/p/google-api-python-client
Other
0 stars 0 forks source link

Authorization of own account for django app #338

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I want to access my own google calendar as part of a web application deployed 
in django. To do this I got the credentials for my google account stored in a 
file (called calendar.dat) which is in the same directory as as the views.py 
file being used for the application. Is there a way to use this file to get my 
credentials. Currently the code is:

from oauth2client.file import Storage

import os.path
import httplib2

module_dir = os.path.dirname(__file__)
file_path = os.path.join(module_dir, calendar.dat)
storage = Storage(file_path)
credentials = storage.get

http = httplib2.Http()
http = credentials.authorize(http)

However, this code returns credentials as None, so it doesn't work in views.py. 
It does work however if I put it in a normal python file and just run it in the 
terminal, as opposed to someone visiting the page in a web browser. Is there a 
way to fix this?

Original issue reported on code.google.com by graylcpu...@gmail.com on 15 Oct 2014 at 7:28