|
@@ -1,16 +1,17 @@
|
|
|
|
+import os
|
|
from django.http import HttpResponse
|
|
from django.http import HttpResponse
|
|
from django.shortcuts import redirect
|
|
from django.shortcuts import redirect
|
|
-from django.urls import reverse
|
|
|
|
import google_auth_oauthlib.flow
|
|
import google_auth_oauthlib.flow
|
|
from django.contrib.auth.decorators import login_required
|
|
from django.contrib.auth.decorators import login_required
|
|
from django.contrib.auth.models import User
|
|
from django.contrib.auth.models import User
|
|
-
|
|
|
|
|
|
+from django.conf import settings
|
|
from .auth_utils import get_access_token, get_google_account_id
|
|
from .auth_utils import get_access_token, get_google_account_id
|
|
|
|
|
|
from .models import UserModel
|
|
from .models import UserModel
|
|
|
|
|
|
|
|
+base_dir = settings.BASE_DIR
|
|
|
|
|
|
-CLIENT_SECRETS_FILE = "client_secrets.json"
|
|
|
|
|
|
+CLIENT_SECRETS_FILE = os.path.join(base_dir, "client_secrets.json")
|
|
SCOPES = ['https://www.googleapis.com/auth/business.manage']
|
|
SCOPES = ['https://www.googleapis.com/auth/business.manage']
|
|
flow = google_auth_oauthlib.flow.Flow.from_client_secrets_file(
|
|
flow = google_auth_oauthlib.flow.Flow.from_client_secrets_file(
|
|
CLIENT_SECRETS_FILE,
|
|
CLIENT_SECRETS_FILE,
|
|
@@ -54,7 +55,6 @@ def oauth2callback(request):
|
|
user_model.refresh_token = credentials.refresh_token
|
|
user_model.refresh_token = credentials.refresh_token
|
|
user_model.gmb_account_id = account_id
|
|
user_model.gmb_account_id = account_id
|
|
user_model.save()
|
|
user_model.save()
|
|
- print(credentials.refresh_token)
|
|
|
|
request.session['credentials'] = credentials_to_dict(credentials)
|
|
request.session['credentials'] = credentials_to_dict(credentials)
|
|
return redirect('token')
|
|
return redirect('token')
|
|
|
|
|