def _get_credentials(self):
client_secret_path = os.path.dirname(self.client_secret)<EOL>auth_token_path = os.path.dirname(self.auth_token)<EOL>if not os.path.exists(auth_token_path):<EOL><INDENT>os.makedirs(auth_token_path)<EOL><DEDENT>if not os.path.exists(client_secret_path):<EOL><INDENT>os.makedirs(client_secret_path)<EOL><DEDENT>flags = tools.argparser.parse_args(args=[])<EOL>store = Storage(self.auth_token)<EOL>credentials = store.get()<EOL>if not credentials or credentials.invalid:<EOL><INDENT>try:<EOL><INDENT>flow = client.flow_from_clientsecrets(self.client_secret, 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><DEDENT>except clientsecrets.InvalidClientSecretsError:<EOL><INDENT>raise Exception("<STR_LIT>")<EOL><DEDENT>"""<STR_LIT>"""<EOL>self.py3.command_run("<STR_LIT>".format(self.py3.get_wm_msg()))<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.