Skip to content

Instantly share code, notes, and snippets.

@oguzhari
Last active September 14, 2022 20:07
Show Gist options
  • Select an option

  • Save oguzhari/7264699830daf4d33529e95e6d133341 to your computer and use it in GitHub Desktop.

Select an option

Save oguzhari/7264699830daf4d33529e95e6d133341 to your computer and use it in GitHub Desktop.
from pydrive.auth import GoogleAuth
def create_user_auth():
gauth = GoogleAuth()
gauth.LoadCredentialsFile('mycreds.txt')
if gauth.credentials is None:
# Eğer mycreds.txt dosyası yoksa, kullanıcıdan kimlik doğrulaması yapılması istenir.
gauth.LocalWebserverAuth()
elif gauth.access_token_expired:
# Kimlik doğrulaması süresi dolmuşsa yeniden kimlik doğrulaması yapılır.
gauth.Refresh()
else:
# Kimlik doğrulaması geçerliyse kimlik doğrulaması yapılması istenmez.
gauth.Authorize()
# Kimlik doğrulaması sonucunda elde edilen bilgiler mycreds.txt dosyasına kaydedilir.
gauth.SaveCredentialsFile('mycreds.txt')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment