'Build a custom authentication flow in a hosted django app for pydrive2

I am using Django as backend.

I need to create a custom auth flow for pydrive2. I cannot use gauth.LocalWebserverAuth() as that is suitable only on local machines.

I see this sample code at pydrive documentation for custom auth flow.

from pydrive2.auth import GoogleAuth

gauth = GoogleAuth()
auth_url = gauth.GetAuthUrl() # Create authentication url user needs to visit
code = AskUserToVisitLinkAndGiveCode(auth_url) # Your customized authentication flow
gauth.Auth(code) # Authorize and build service from the code

AskUserToVisitLinkAndGiveCode is the part that I am unable to understand. What should this function do? Should my backend redirect to the URI that I added as the redirect URI on google drive console? Or should I redirect the user to the auth_url link?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source