Hello community,

here is the log from the commit of package python-pydata-google-auth for 
openSUSE:Factory checked in at 2020-02-03 11:13:40
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-pydata-google-auth (Old)
 and      /work/SRC/openSUSE:Factory/.python-pydata-google-auth.new.26092 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-pydata-google-auth"

Mon Feb  3 11:13:40 2020 rev:2 rq:768932 version:0.2.1

Changes:
--------
--- 
/work/SRC/openSUSE:Factory/python-pydata-google-auth/python-pydata-google-auth.changes
      2019-07-26 12:43:32.601825525 +0200
+++ 
/work/SRC/openSUSE:Factory/.python-pydata-google-auth.new.26092/python-pydata-google-auth.changes
   2020-02-03 11:13:46.537858801 +0100
@@ -1,0 +2,19 @@
+Thu Jan 30 15:20:11 UTC 2020 - Todd R <toddrme2...@gmail.com>
+
+- Update to 0.2.1
+  * Re-enable ``auth_local_webserver`` in ``default`` method. Show warning,
+    rather than fallback to console.
+- Update to 0.2.0
+  + Deprecations
+    * **Deprecate** ``auth_local_webserver`` argument in favor of
+      ``use_local_webserver`` argument
+  + New Features
+    * Adds :func:`pydata_google_auth.save_user_credentials` function to get 
user
+      credentials and then save them to a specified JSON path.
+  + Bug Fixes
+    * Update OAuth2 token endpoint to latest URI from Google.
+    * Don't raise error when the ``APPDATA`` environment variable isn't set on
+      Windows.
+
+
+-------------------------------------------------------------------

Old:
----
  pydata-google-auth-0.1.3.tar.gz

New:
----
  pydata-google-auth-0.2.1.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-pydata-google-auth.spec ++++++
--- /var/tmp/diff_new_pack.Cl8fwY/_old  2020-02-03 11:13:47.177859124 +0100
+++ /var/tmp/diff_new_pack.Cl8fwY/_new  2020-02-03 11:13:47.177859124 +0100
@@ -1,7 +1,7 @@
 #
 # spec file for package python-pydata-google-auth
 #
-# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2020 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -12,26 +12,27 @@
 # license that conforms to the Open Source Definition (Version 1.9)
 # published by the Open Source Initiative.
 
-# Please submit bugfixes or comments via http://bugs.opensuse.org/
+# Please submit bugfixes or comments via https://bugs.opensuse.org/
+#
 
 
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
 Name:           python-pydata-google-auth
-Version:        0.1.3
+Version:        0.2.1
 Release:        0
-License:        BSD-3-Clause
 Summary:        PyData helpers for authenticating to Google APIs
-Url:            https://github.com/pydata/pydata-google-auth
+License:        BSD-3-Clause
 Group:          Development/Languages/Python
+URL:            https://github.com/pydata/pydata-google-auth
 Source:         
https://github.com/pydata/pydata-google-auth/archive/%{version}.tar.gz#/pydata-google-auth-%{version}.tar.gz
 BuildRequires:  %{python_module setuptools}
 BuildRequires:  fdupes
 BuildRequires:  python-rpm-macros
 # SECTION test requirements
+BuildRequires:  %{python_module google-auth-oauthlib}
+BuildRequires:  %{python_module google-auth}
 BuildRequires:  %{python_module pyfakefs}
 BuildRequires:  %{python_module pytest}
-BuildRequires:  %{python_module google-auth}
-BuildRequires:  %{python_module google-auth-oauthlib}
 BuildRequires:  python-mock
 # /SECTION
 Requires:       python-google-auth
@@ -55,7 +56,7 @@
 %python_expand %fdupes %{buildroot}%{$python_sitelib}
 
 %check
-%python_exec setup.py test
+%pytest tests/unit
 
 %files %{python_files}
 %doc README.rst

++++++ pydata-google-auth-0.1.3.tar.gz -> pydata-google-auth-0.2.1.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pydata-google-auth-0.1.3/docs/source/api.rst 
new/pydata-google-auth-0.2.1/docs/source/api.rst
--- old/pydata-google-auth-0.1.3/docs/source/api.rst    2019-02-26 
23:04:04.000000000 +0100
+++ new/pydata-google-auth-0.2.1/docs/source/api.rst    2019-12-13 
00:04:28.000000000 +0100
@@ -9,6 +9,7 @@
 
     default
     get_user_credentials
+    save_user_credentials
     cache.CredentialsCache
     cache.READ_WRITE
     cache.REAUTH
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pydata-google-auth-0.1.3/docs/source/changelog.rst 
new/pydata-google-auth-0.2.1/docs/source/changelog.rst
--- old/pydata-google-auth-0.1.3/docs/source/changelog.rst      2019-02-26 
23:04:04.000000000 +0100
+++ new/pydata-google-auth-0.2.1/docs/source/changelog.rst      2019-12-13 
00:04:28.000000000 +0100
@@ -1,6 +1,35 @@
 Changelog
 =========
 
+.. _changelog-0.2.1:
+
+0.2.1 / (2019-12-12)
+--------------------
+
+- Re-enable ``auth_local_webserver`` in ``default`` method. Show warning,
+  rather than fallback to console.
+
+.. _changelog-0.2.0:
+
+0.2.0 / (2019-12-12)
+--------------------
+
+- **Deprecate** ``auth_local_webserver`` argument in favor of
+  ``use_local_webserver`` argument (:issue:`20`).
+
+New Features
+^^^^^^^^^^^^^
+
+- Adds :func:`pydata_google_auth.save_user_credentials` function to get user
+  credentials and then save them to a specified JSON path. (:issue:`22`)
+
+Bug Fixes
+^^^^^^^^^
+
+- Update OAuth2 token endpoint to latest URI from Google. (:issue:`27`)
+- Don't raise error when the ``APPDATA`` environment variable isn't set on
+  Windows. (:issue:`29`)
+
 .. _changelog-0.1.3:
 
 0.1.3 / (2019-02-26)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/pydata-google-auth-0.1.3/pydata_google_auth/__init__.py 
new/pydata-google-auth-0.2.1/pydata_google_auth/__init__.py
--- old/pydata-google-auth-0.1.3/pydata_google_auth/__init__.py 2019-02-26 
23:04:04.000000000 +0100
+++ new/pydata-google-auth-0.2.1/pydata_google_auth/__init__.py 2019-12-13 
00:04:28.000000000 +0100
@@ -1,5 +1,6 @@
 from .auth import default
 from .auth import get_user_credentials
+from .auth import save_user_credentials
 from ._version import get_versions
 
 versions = get_versions()
@@ -11,4 +12,10 @@
 This package provides helpers for fetching Google API credentials.
 """
 
-__all__ = ["__version__", "__git_revision__", "default", 
"get_user_credentials"]
+__all__ = [
+    "__version__",
+    "__git_revision__",
+    "default",
+    "get_user_credentials",
+    "save_user_credentials",
+]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/pydata-google-auth-0.1.3/pydata_google_auth/_version.py 
new/pydata-google-auth-0.2.1/pydata_google_auth/_version.py
--- old/pydata-google-auth-0.1.3/pydata_google_auth/_version.py 2019-02-26 
23:04:04.000000000 +0100
+++ new/pydata-google-auth-0.2.1/pydata_google_auth/_version.py 2019-12-13 
00:04:28.000000000 +0100
@@ -22,9 +22,9 @@
     # setup.py/versioneer.py will grep for the variable names, so they must
     # each be defined on a line of their own. _version.py will just call
     # get_keywords().
-    git_refnames = " (tag: 0.1.3)"
-    git_full = "1bbc5a62a7feb7f61b7be3048a3ba85179d89c08"
-    git_date = "2019-02-26 16:04:04 -0600"
+    git_refnames = " (HEAD -> master, tag: 0.2.1)"
+    git_full = "d0644d2e0d760ee201f4f4259e7905981e205c69"
+    git_date = "2019-12-12 15:04:28 -0800"
     keywords = {"refnames": git_refnames, "full": git_full, "date": git_date}
     return keywords
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pydata-google-auth-0.1.3/pydata_google_auth/auth.py 
new/pydata-google-auth-0.2.1/pydata_google_auth/auth.py
--- old/pydata-google-auth-0.1.3/pydata_google_auth/auth.py     2019-02-26 
23:04:04.000000000 +0100
+++ new/pydata-google-auth-0.2.1/pydata_google_auth/auth.py     2019-12-13 
00:04:28.000000000 +0100
@@ -17,6 +17,8 @@
 
 CLIENT_ID = 
"262006177488-3425ks60hkk80fssi9vpohv88g6q1iqd.apps.googleusercontent.com"
 CLIENT_SECRET = "JSF-iczmzEgbTR-XK-2xaWAc"
+GOOGLE_AUTH_URI = "https://accounts.google.com/o/oauth2/auth";
+GOOGLE_TOKEN_URI = "https://oauth2.googleapis.com/token";
 
 
 def default(
@@ -24,7 +26,8 @@
     client_id=None,
     client_secret=None,
     credentials_cache=cache.READ_WRITE,
-    auth_local_webserver=False,
+    use_local_webserver=False,
+    auth_local_webserver=None,
 ):
     """
     Get credentials and default project for accessing Google APIs.
@@ -64,10 +67,12 @@
         ``$HOME/.config/pydata/pydata_google_credentials.json`` or
         ``$APPDATA/.config/pydata/pydata_google_credentials.json`` on
         Windows.
-    auth_local_webserver : bool, optional
+    use_local_webserver : bool, optional
         Use a local webserver for the user authentication
         :class:`google_auth_oauthlib.flow.InstalledAppFlow`. Defaults to
         ``False``, which requests a token via the console.
+    auth_local_webserver : deprecated
+        Use the ``use_local_webserver`` parameter instead.
 
     Returns
     -------
@@ -84,6 +89,9 @@
     pydata_google_auth.exceptions.PyDataCredentialsError
         If unable to get valid credentials.
     """
+    if auth_local_webserver is not None:
+        use_local_webserver = auth_local_webserver
+
     # Try to retrieve Application Default Credentials
     credentials, default_project = get_application_default_credentials(scopes)
 
@@ -95,7 +103,7 @@
         client_id=client_id,
         client_secret=client_secret,
         credentials_cache=credentials_cache,
-        auth_local_webserver=auth_local_webserver,
+        use_local_webserver=use_local_webserver,
     )
 
     if not credentials or not credentials.valid:
@@ -150,7 +158,8 @@
     client_id=None,
     client_secret=None,
     credentials_cache=cache.READ_WRITE,
-    auth_local_webserver=False,
+    use_local_webserver=False,
+    auth_local_webserver=None,
 ):
     """
     Gets user account credentials.
@@ -199,10 +208,12 @@
         ``$HOME/.config/pydata/pydata_google_credentials.json`` or
         ``$APPDATA/.config/pydata/pydata_google_credentials.json`` on
         Windows.
-    auth_local_webserver : bool, optional
+    use_local_webserver : bool, optional
         Use a local webserver for the user authentication
         :class:`google_auth_oauthlib.flow.InstalledAppFlow`. Defaults to
         ``False``, which requests a token via the console.
+    auth_local_webserver : deprecated
+        Use the ``use_local_webserver`` parameter instead.
 
     Returns
     -------
@@ -214,6 +225,9 @@
     pydata_google_auth.exceptions.PyDataCredentialsError
         If unable to get valid user credentials.
     """
+    if auth_local_webserver is not None:
+        use_local_webserver = auth_local_webserver
+
     # Use None as default for client_id and client_secret so that the values
     # aren't included in the docs. A string of bytes isn't useful for the
     # documentation and might encourage the values to be used outside of this
@@ -230,8 +244,8 @@
             "client_id": client_id,
             "client_secret": client_secret,
             "redirect_uris": ["urn:ietf:wg:oauth:2.0:oob"],
-            "auth_uri": "https://accounts.google.com/o/oauth2/auth";,
-            "token_uri": "https://accounts.google.com/o/oauth2/token";,
+            "auth_uri": GOOGLE_AUTH_URI,
+            "token_uri": GOOGLE_TOKEN_URI,
         }
     }
 
@@ -241,7 +255,7 @@
         )
 
         try:
-            if auth_local_webserver:
+            if use_local_webserver:
                 credentials = app_flow.run_local_server()
             else:
                 credentials = app_flow.run_console()
@@ -257,3 +271,84 @@
         credentials.refresh(request)
 
     return credentials
+
+
+def save_user_credentials(
+    scopes, path, client_id=None, client_secret=None, use_local_webserver=False
+):
+    """
+    Gets user account credentials and saves them to a JSON file at ``path``.
+
+    This function authenticates using user credentials by going through the
+    OAuth 2.0 flow.
+
+    Parameters
+    ----------
+
+    scopes : list[str]
+        A list of scopes to use when authenticating to Google APIs. See the
+        `list of OAuth 2.0 scopes for Google APIs
+        <https://developers.google.com/identity/protocols/googlescopes>`_.
+    path : str
+        Path to save credentials JSON file.
+    client_id : str, optional
+        The client secrets to use when prompting for user credentials.
+        Defaults to a client ID associated with pydata-google-auth.
+
+        If you are a tool or library author, you must override the default
+        value with a client ID associated with your project. Per the `Google
+        APIs terms of service <https://developers.google.com/terms/>`_, you
+        must not mask your API client's identity when using Google APIs.
+    client_secret : str, optional
+        The client secrets to use when prompting for user credentials.
+        Defaults to a client secret associated with pydata-google-auth.
+
+        If you are a tool or library author, you must override the default
+        value with a client secret associated with your project. Per the
+        `Google APIs terms of service
+        <https://developers.google.com/terms/>`_, you must not mask your API
+        client's identity when using Google APIs.
+    use_local_webserver : bool, optional
+        Use a local webserver for the user authentication
+        :class:`google_auth_oauthlib.flow.InstalledAppFlow`. Defaults to
+        ``False``, which requests a token via the console.
+
+    Returns
+    -------
+
+    None
+
+    Raises
+    ------
+    pydata_google_auth.exceptions.PyDataCredentialsError
+        If unable to get valid user credentials.
+
+    Examples
+    --------
+
+    Get credentials for Google Cloud Platform and save them to
+    ``/home/username/keys/google-credentials.json``.
+
+    .. code-block:: python
+
+       pydata_google_auth.save_user_credentials(
+           ["https://www.googleapis.com/auth/cloud-platform";],
+           "/home/username/keys/google-credentials.json",
+           use_local_webserver=True,
+       )
+
+    Set the ``GOOGLE_APPLICATION_CREDENTIALS`` environment variable to use
+    these credentials with Google Application Default Credentials.
+
+    .. code-block:: bash
+
+       export 
GOOGLE_APPLICATION_CREDENTIALS='/home/username/keys/google-credentials.json'
+    """
+    credentials = get_user_credentials(
+        scopes,
+        client_id=client_id,
+        client_secret=client_secret,
+        credentials_cache=cache.NOOP,
+        use_local_webserver=use_local_webserver,
+    )
+    cache._save_user_account_credentials(credentials, path)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pydata-google-auth-0.1.3/pydata_google_auth/cache.py 
new/pydata-google-auth-0.2.1/pydata_google_auth/cache.py
--- old/pydata-google-auth-0.1.3/pydata_google_auth/cache.py    2019-02-26 
23:04:04.000000000 +0100
+++ new/pydata-google-auth-0.2.1/pydata_google_auth/cache.py    2019-12-13 
00:04:28.000000000 +0100
@@ -25,9 +25,11 @@
     str
         Path to the Google user credentials
     """
+    config_path = None
+
     if os.name == "nt":
-        config_path = os.environ["APPDATA"]
-    else:
+        config_path = os.getenv("APPDATA")
+    if not config_path:
         config_path = os.path.join(os.path.expanduser("~"), ".config")
 
     config_path = os.path.join(config_path, credentials_dirname)
@@ -111,6 +113,10 @@
                 "client_id": credentials.client_id,
                 "client_secret": credentials.client_secret,
                 "scopes": credentials.scopes,
+                # Required for Application Default Credentials to detect the
+                # credentials type. See:
+                # https://github.com/pydata/pydata-google-auth/issues/22
+                "type": "authorized_user",
             }
             json.dump(credentials_json, credentials_file)
     except IOError:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pydata-google-auth-0.1.3/tests/system/test_auth.py 
new/pydata-google-auth-0.2.1/tests/system/test_auth.py
--- old/pydata-google-auth-0.1.3/tests/system/test_auth.py      2019-02-26 
23:04:04.000000000 +0100
+++ new/pydata-google-auth-0.2.1/tests/system/test_auth.py      2019-12-13 
00:04:28.000000000 +0100
@@ -14,9 +14,8 @@
 def test_default_gets_valid_credentials():
     import pydata_google_auth
 
-    credentials, _ = pydata_google_auth.default(TEST_SCOPES, 
auth_local_webserver=True)
+    credentials, _ = pydata_google_auth.default(TEST_SCOPES, 
use_local_webserver=True)
     assert credentials.valid
-    assert credentials.has_scopes(TEST_SCOPES)
 
 
 def test_default_gets_user_credentials():
@@ -25,22 +24,20 @@
     # Mock google.auth.default to fail, forcing user credentials.
     with mock.patch("google.auth.default", 
side_effect=DefaultCredentialsError()):
         credentials, _ = pydata_google_auth.default(
-            TEST_SCOPES, auth_local_webserver=True
+            TEST_SCOPES, use_local_webserver=True
         )
 
     assert credentials.valid
-    assert credentials.has_scopes(TEST_SCOPES)
 
 
 def test_get_user_credentials_gets_valid_credentials():
     import pydata_google_auth
 
     credentials = pydata_google_auth.get_user_credentials(
-        TEST_SCOPES, auth_local_webserver=True
+        TEST_SCOPES, use_local_webserver=True
     )
 
     assert credentials.valid
-    assert credentials.has_scopes(TEST_SCOPES)
 
 
 def test_get_user_credentials_noop_gets_valid_credentials():
@@ -50,7 +47,7 @@
     credentials = pydata_google_auth.get_user_credentials(
         TEST_SCOPES,
         credentials_cache=pydata_google_auth.cache.NOOP,
-        auth_local_webserver=True,
+        use_local_webserver=True,
     )
 
     assert credentials.valid
@@ -64,7 +61,7 @@
     credentials = pydata_google_auth.get_user_credentials(
         TEST_SCOPES,
         credentials_cache=pydata_google_auth.cache.REAUTH,
-        auth_local_webserver=True,
+        use_local_webserver=True,
     )
 
     assert credentials.valid
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pydata-google-auth-0.1.3/tests/unit/test_cache.py 
new/pydata-google-auth-0.2.1/tests/unit/test_cache.py
--- old/pydata-google-auth-0.1.3/tests/unit/test_cache.py       2019-02-26 
23:04:04.000000000 +0100
+++ new/pydata-google-auth-0.2.1/tests/unit/test_cache.py       2019-12-13 
00:04:28.000000000 +0100
@@ -34,6 +34,19 @@
     assert module_under_test.NOOP is not None
 
 
+def test__get_default_credentials_path_windows_wo_appdata(
+    module_under_test, monkeypatch
+):
+    # Ensure default path returns something sensible on Windows, even if
+    # APPDATA is not set. See:
+    # https://github.com/pydata/pydata-google-auth/issues/29
+    monkeypatch.setattr(os, "name", "nt")
+    monkeypatch.delenv("APPDATA", raising=False)
+
+    creds_path = module_under_test._get_default_credentials_path("dirname", 
"filename")
+    assert creds_path is not None
+
+
 def test__save_user_account_credentials_wo_directory(module_under_test, fs):
     """Directories should be created if they don't exist."""
 
@@ -55,6 +68,11 @@
         serialized_data = json.load(fp)
     assert serialized_data["refresh_token"] == "refresh_token"
 
+    # Set the type so that the cached credentials file can be used as
+    # application default credentials. See:
+    # https://github.com/pydata/pydata-google-auth/issues/22
+    assert serialized_data["type"] == "authorized_user"
+
 
 def test_ReadWriteCredentialsCache_sets_path(module_under_test):
     """ReadWriteCredentialsCache ctor should respect dirname and filename.


Reply via email to