コード例 #1
0
def test_get_service_account_credentials_private_key_contents(
        private_key_contents):
    from google.auth.credentials import Credentials
    credentials, project_id = auth.get_service_account_credentials(
        private_key_contents)
    assert isinstance(credentials, Credentials)
    assert auth._try_credentials(project_id, credentials) is not None
コード例 #2
0
def _check_if_can_get_correct_default_credentials():
    # Checks if "Application Default Credentials" can be fetched
    # from the environment the tests are running in.
    # See https://github.com/pandas-dev/pandas/issues/13577

    import google.auth
    from google.auth.exceptions import DefaultCredentialsError
    import pandas_gbq.auth
    import pandas_gbq.gbq

    try:
        credentials, project = google.auth.default(
            scopes=pandas_gbq.auth.SCOPES)
    except (DefaultCredentialsError, IOError):
        return False

    return auth._try_credentials(project, credentials) is not None