def get_credentials():
home_dir = os.path.expanduser('<STR_LIT>')<EOL>credential_dir = os.path.join(home_dir, '<STR_LIT>')<EOL>if not os.path.exists(credential_dir):<EOL><INDENT>os.makedirs(credential_dir)<EOL><DEDENT>credential_path = os.path.join(credential_dir,<EOL>'<STR_LIT>')<EOL>store = Storage(credential_path)<EOL>credentials = store.get()<EOL>if not credentials or credentials.invalid:<EOL><INDENT>flow = client.flow_from_clientsecrets(CLIENT_SECRET_FILE, SCOPES)<EOL>flow.user_agent = APPLICATION_NAME<EOL>if flags:<EOL><INDENT>credentials = tools.run_flow(flow, store, flags)<EOL><DEDENT>else: <EOL><INDENT>credentials = tools.run(flow, store)<EOL><DEDENT>print('<STR_LIT>' + credential_path)<EOL><DEDENT>return credentials<EOL>
Gets valid user credentials from storage.

    If nothing has been stored, or if the stored credentials are invalid,
    the OAuth2 flow is completed to obtain the new credentials.

    Returns:
        Credentials, the obtained credential.