python - Working with google calendar api in Django -


as start wanted view events google calendar in django, tried quickstart example, run successfully, after installing google-api-python-client , downloading json file.

i followed google's example page, sample didn't seem work, got error when running python manage.py makemigrations:

"must specify either google_oauth2_client_secrets_json, or "django.core.exceptions.improperlyconfigured: must specify either google_oauth2_client_secrets_json, or both google_oauth2_client_id , google_oauth2_client_secret in settings.py 

even after commented google_oauth2_client_id , google_oauth2_client_secret settings.py

views.py:

client_secrets = os.path.join(os.path.dirname(__file__), '..', 'client_secret.json')  flow = flow_from_clientsecrets( client_secrets, scope='https://www.googleapis.com/auth/calendar.readonly', redirect_uri='http://www.notify-me.ua:8000/complete/google-oauth2/')   @login_required def home(request):     storage = storage(credentialsmodel, 'id', request.user, 'credential')     credential = storage.get()     if credential none or credential.invalid == true:         flow.params['state'] = xsrfutil.generate_token(settings.secret_key,                     request.user)         authorize_url = flow.step1_get_authorize_url()         return httpresponseredirect(authorize_url)     else:         http = httplib2.http()         http = credential.authorize(http)         service = build("calendar", "v3", http=http)          = datetime.datetime.utcnow().isoformat() + 'z'         eventsresult = service.events()          return render(request, 'home.html', {             'eventsresult': eventsresult,             })  @login_required def auth_return(request):     if not xsrfutil.validate_token(settings.secret_key, request.request['state'], request.user):         return httpresponsebadrequest()     credential = flow.step2_exchange(request.request)     storage = storage(credentialsmodel, 'id', request.user, 'credential')     storage.put(credential)     return httpresponseredirect("/") 

models.py:

from django.db import models django.contrib.auth.models import user oauth2client.contrib.django_util.models import credentialsfield  class credentialsmodel(models.model):     id = models.foreignkey(user, primary_key=true)     credential = credentialsfield() 

i want view events google calendar.

i getting error because there line missing in settings.py:

google_oauth2_client_secrets_json = 'client_secret.json' 

everything else in docs.


Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -