Skip to content

Commit

Permalink
Ask users to provide a new google oauth credential if current one is …
Browse files Browse the repository at this point in the history
…invalid
  • Loading branch information
FrankApiyo committed Oct 17, 2022
1 parent 1af1dd1 commit a90e8d3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions onadata/libs/utils/api_export_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,7 @@ def generate_google_web_flow(request):

def _get_google_credential(request):
credential = None
storage = None
if request.user.is_authenticated:
try:
storage = TokenStorageModel.objects.get(id=request.user)
Expand All @@ -636,6 +637,11 @@ def _get_google_credential(request):
elif request.session.get("access_token"):
credential = Credentials(token=request.session["access_token"])

if credential and not credential.valid:
# We need the user to provide a new crential
storage.delete()
credential = None

if not credential:
google_flow = generate_google_web_flow(request)
authorization_url, _state = google_flow.authorization_url(
Expand Down

0 comments on commit a90e8d3

Please sign in to comment.