INNER CODE UNIT · Python

_retrieve_client_credentials

Squarespace/datasheets · datasheets/client.py:93

    def _retrieve_client_credentials(self):
        """Get valid user credentials

        If storage=True, then first look in ``$DATASHEETS_CREDENTIALS_PATH``
        (default: ``~/.datasheets/client_credentials.json``) to see if authorized credentials have
        been stored. The client credentials are basically an access token that expires. If nothing
        has been stored or if the stored credentials are invalid, the OAuth2 flow is completed to
        obtain new credentials using the client secrets as the means of verifying that the user
        should be granted access. The resulting credentials will be stored at that same path unless
        storage=False, in which case the OAuth2 flow will be executed to obtain new user
        credentials regardless but the credentials will not be stored. The storage=False mode
        deliberately does not store credentials to disk in order to allow for use of the library
        in multi-user environments.
        """
        if self.use_storage:
            unexpanded_credential_path = os.environ.get('DATASHEETS_CREDENTIALS_PATH',
                                                        '~/.datasheets/client_credentials.json')
            credential_path = os.path.expanduser(unexpanded_credential_path)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…