def _get_credentials(self):
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(<EOL>credential_dir,<EOL>'<STR_LIT>',<EOL>)<EOL>store = Storage(credential_path)<EOL>credentials = store.get()<EOL>if not credentials or credentials.invalid:<EOL><INDENT>with NamedTemporaryFile(suffix='<STR_LIT>') as f:<EOL><INDENT>data = ujson.dumps(settings.GOOGLE_SHEET_SYNC['<STR_LIT>'])<EOL>f.write(data.encode('<STR_LIT:utf-8>'))<EOL>f.flush()<EOL>flow = client.flow_from_clientsecrets(f.name, SCOPES)<EOL><DEDENT>flow.user_agent = APPLICATION_NAME<EOL>credentials = tools.run_flow(flow, store, self.flags)<EOL>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.