New upstream release.
Debian Janitor
2 years ago
0 | Apache License | |
0 | ||
1 | Apache License | |
1 | 2 | Version 2.0, January 2004 |
2 | https://www.apache.org/licenses/ | |
3 | http://www.apache.org/licenses/ | |
3 | 4 | |
4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION |
5 | 6 | |
191 | 192 | you may not use this file except in compliance with the License. |
192 | 193 | You may obtain a copy of the License at |
193 | 194 | |
194 | https://www.apache.org/licenses/LICENSE-2.0 | |
195 | http://www.apache.org/licenses/LICENSE-2.0 | |
195 | 196 | |
196 | 197 | Unless required by applicable law or agreed to in writing, software |
197 | 198 | distributed under the License is distributed on an "AS IS" BASIS, |
15 | 15 | |
16 | 16 | # Generated by synthtool. DO NOT EDIT! |
17 | 17 | include README.rst LICENSE |
18 | recursive-include google *.json *.proto | |
18 | recursive-include google *.json *.proto py.typed | |
19 | 19 | recursive-include tests * |
20 | 20 | global-exclude *.py[co] |
21 | 21 | global-exclude __pycache__ |
22 | 22 | |
23 | 23 | # Exclude scripts for samples readmegen |
24 | prune scripts/readme-gen⏎ | |
24 | prune scripts/readme-gen |
0 | 0 | Metadata-Version: 2.1 |
1 | 1 | Name: google-auth-oauthlib |
2 | Version: 0.4.2 | |
2 | Version: 0.5.0 | |
3 | 3 | Summary: Google Authentication Library |
4 | 4 | Home-page: https://github.com/GoogleCloudPlatform/google-auth-library-python-oauthlib |
5 | 5 | Author: Google Cloud Platform |
6 | 6 | Author-email: jonwayne+google-auth@google.com |
7 | 7 | License: Apache 2.0 |
8 | Description: oauthlib integration for Google Auth | |
9 | ==================================== | |
10 | ||
11 | |pypi| | |
12 | ||
13 | This library provides `oauthlib`_ integration with `google-auth`_. | |
14 | ||
15 | .. |build| image:: https://travis-ci.org/googleapis/google-auth-library-python-oauthlib.svg?branch=master | |
16 | :target: https://travis-ci.org/googleapis/google-auth-library-python-oauthlib | |
17 | .. |docs| image:: https://readthedocs.org/projects/google-auth-oauthlib/badge/?version=latest | |
18 | :target: https://google-auth-oauthlib.readthedocs.io/en/latest/ | |
19 | .. |pypi| image:: https://img.shields.io/pypi/v/google-auth-oauthlib.svg | |
20 | :target: https://pypi.python.org/pypi/google-auth-oauthlib | |
21 | ||
22 | .. _oauthlib: https://github.com/idan/oauthlib | |
23 | .. _google-auth: https://github.com/googleapis/google-auth-library-python | |
24 | ||
25 | Installing | |
26 | ---------- | |
27 | ||
28 | You can install using `pip`_:: | |
29 | ||
30 | $ pip install google-auth-oauthlib | |
31 | ||
32 | .. _pip: https://pip.pypa.io/en/stable/ | |
33 | ||
34 | Documentation | |
35 | ------------- | |
36 | ||
37 | The latest documentation is available at `google-auth-oauthlib.readthedocs.io`_. | |
38 | ||
39 | .. _google-auth-oauthlib.readthedocs.io: http://google-auth-oauthlib.readthedocs.io/ | |
40 | ||
41 | License | |
42 | ------- | |
43 | ||
44 | Apache 2.0 - See `the LICENSE`_ for more information. | |
45 | ||
46 | .. _the LICENSE: https://github.com/googleapis/google-auth-library-python-oauthlib/blob/master/LICENSE | |
47 | ||
48 | 8 | Keywords: google auth oauth client oauthlib |
49 | 9 | Platform: UNKNOWN |
50 | 10 | Classifier: Programming Language :: Python :: 3 |
52 | 12 | Classifier: Programming Language :: Python :: 3.7 |
53 | 13 | Classifier: Programming Language :: Python :: 3.8 |
54 | 14 | Classifier: Programming Language :: Python :: 3.9 |
15 | Classifier: Programming Language :: Python :: 3.10 | |
55 | 16 | Classifier: Development Status :: 3 - Alpha |
56 | 17 | Classifier: Intended Audience :: Developers |
57 | 18 | Classifier: License :: OSI Approved :: Apache Software License |
62 | 23 | Classifier: Topic :: Internet :: WWW/HTTP |
63 | 24 | Requires-Python: >=3.6 |
64 | 25 | Provides-Extra: tool |
26 | License-File: LICENSE | |
27 | ||
28 | oauthlib integration for Google Auth | |
29 | ==================================== | |
30 | ||
31 | |pypi| | |
32 | ||
33 | This library provides `oauthlib`_ integration with `google-auth`_. | |
34 | ||
35 | .. |build| image:: https://travis-ci.org/googleapis/google-auth-library-python-oauthlib.svg?branch=main | |
36 | :target: https://travis-ci.org/googleapis/google-auth-library-python-oauthlib | |
37 | .. |docs| image:: https://readthedocs.org/projects/google-auth-oauthlib/badge/?version=latest | |
38 | :target: https://google-auth-oauthlib.readthedocs.io/en/latest/ | |
39 | .. |pypi| image:: https://img.shields.io/pypi/v/google-auth-oauthlib.svg | |
40 | :target: https://pypi.python.org/pypi/google-auth-oauthlib | |
41 | ||
42 | .. _oauthlib: https://github.com/idan/oauthlib | |
43 | .. _google-auth: https://github.com/googleapis/google-auth-library-python | |
44 | ||
45 | Installing | |
46 | ---------- | |
47 | ||
48 | You can install using `pip`_:: | |
49 | ||
50 | $ pip install google-auth-oauthlib | |
51 | ||
52 | .. _pip: https://pip.pypa.io/en/stable/ | |
53 | ||
54 | Documentation | |
55 | ------------- | |
56 | ||
57 | The latest documentation is available at `google-auth-oauthlib.readthedocs.io`_. | |
58 | ||
59 | .. _google-auth-oauthlib.readthedocs.io: http://google-auth-oauthlib.readthedocs.io/ | |
60 | ||
61 | Supported Python Versions | |
62 | ------------------------- | |
63 | Python >= 3.6 | |
64 | ||
65 | ||
66 | Unsupported Python Versions | |
67 | --------------------------- | |
68 | ||
69 | Python == 2.7, Python == 3.5. | |
70 | ||
71 | The last version of this library compatible with Python 2.7 and 3.5 is | |
72 | `google-auth-oauthlib==0.4.1`. | |
73 | ||
74 | License | |
75 | ------- | |
76 | ||
77 | Apache 2.0 - See `the LICENSE`_ for more information. | |
78 | ||
79 | .. _the LICENSE: https://github.com/googleapis/google-auth-library-python-oauthlib/blob/main/LICENSE | |
80 | ||
81 |
4 | 4 | |
5 | 5 | This library provides `oauthlib`_ integration with `google-auth`_. |
6 | 6 | |
7 | .. |build| image:: https://travis-ci.org/googleapis/google-auth-library-python-oauthlib.svg?branch=master | |
7 | .. |build| image:: https://travis-ci.org/googleapis/google-auth-library-python-oauthlib.svg?branch=main | |
8 | 8 | :target: https://travis-ci.org/googleapis/google-auth-library-python-oauthlib |
9 | 9 | .. |docs| image:: https://readthedocs.org/projects/google-auth-oauthlib/badge/?version=latest |
10 | 10 | :target: https://google-auth-oauthlib.readthedocs.io/en/latest/ |
30 | 30 | |
31 | 31 | .. _google-auth-oauthlib.readthedocs.io: http://google-auth-oauthlib.readthedocs.io/ |
32 | 32 | |
33 | Supported Python Versions | |
34 | ------------------------- | |
35 | Python >= 3.6 | |
36 | ||
37 | ||
38 | Unsupported Python Versions | |
39 | --------------------------- | |
40 | ||
41 | Python == 2.7, Python == 3.5. | |
42 | ||
43 | The last version of this library compatible with Python 2.7 and 3.5 is | |
44 | `google-auth-oauthlib==0.4.1`. | |
45 | ||
33 | 46 | License |
34 | 47 | ------- |
35 | 48 | |
36 | 49 | Apache 2.0 - See `the LICENSE`_ for more information. |
37 | 50 | |
38 | .. _the LICENSE: https://github.com/googleapis/google-auth-library-python-oauthlib/blob/master/LICENSE | |
51 | .. _the LICENSE: https://github.com/googleapis/google-auth-library-python-oauthlib/blob/main/LICENSE |
0 | google-auth-oauthlib (0.4.2-2) UNRELEASED; urgency=medium | |
0 | google-auth-oauthlib (0.5.0-1) UNRELEASED; urgency=medium | |
1 | 1 | |
2 | 2 | * Set upstream metadata fields: Repository, Repository-Browse. |
3 | 3 | * Update standards version to 4.5.1, no changes needed. |
4 | * New upstream release. | |
4 | 5 | |
5 | -- Debian Janitor <janitor@jelmer.uk> Wed, 03 Feb 2021 00:01:33 -0000 | |
6 | -- Debian Janitor <janitor@jelmer.uk> Sat, 05 Mar 2022 06:36:36 -0000 | |
6 | 7 | |
7 | 8 | google-auth-oauthlib (0.4.2-1) unstable; urgency=medium |
8 | 9 |
14 | 14 | """OAuth 2.0 Authorization Flow |
15 | 15 | |
16 | 16 | This module provides integration with `requests-oauthlib`_ for running the |
17 | `OAuth 2.0 Authorization Flow`_ and acquiring user credentials. | |
18 | ||
19 | Here's an example of using :class:`Flow` with the installed application | |
20 | authorization flow:: | |
21 | ||
22 | from google_auth_oauthlib.flow import Flow | |
17 | `OAuth 2.0 Authorization Flow`_ and acquiring user credentials. See | |
18 | `Using OAuth 2.0 to Access Google APIs`_ for an overview of OAuth 2.0 | |
19 | authorization scenarios Google APIs support. | |
20 | ||
21 | Here's an example of using :class:`InstalledAppFlow`:: | |
22 | ||
23 | from google_auth_oauthlib.flow import InstalledAppFlow | |
23 | 24 | |
24 | 25 | # Create the flow using the client secrets file from the Google API |
25 | 26 | # Console. |
26 | flow = Flow.from_client_secrets_file( | |
27 | 'path/to/client_secrets.json', | |
28 | scopes=['profile', 'email'], | |
29 | redirect_uri='urn:ietf:wg:oauth:2.0:oob') | |
30 | ||
31 | # Tell the user to go to the authorization URL. | |
32 | auth_url, _ = flow.authorization_url(prompt='consent') | |
33 | ||
34 | print('Please go to this URL: {}'.format(auth_url)) | |
35 | ||
36 | # The user will get an authorization code. This code is used to get the | |
37 | # access token. | |
38 | code = input('Enter the authorization code: ') | |
39 | flow.fetch_token(code=code) | |
27 | flow = InstalledAppFlow.from_client_secrets_file( | |
28 | 'client_secrets.json', | |
29 | scopes=['profile', 'email']) | |
30 | ||
31 | flow.run_local_server() | |
40 | 32 | |
41 | 33 | # You can use flow.credentials, or you can just get a requests session |
42 | 34 | # using flow.authorized_session. |
43 | 35 | session = flow.authorized_session() |
44 | print(session.get('https://www.googleapis.com/userinfo/v2/me').json()) | |
45 | ||
46 | This particular flow can be handled entirely by using | |
47 | :class:`InstalledAppFlow`. | |
36 | ||
37 | profile_info = session.get( | |
38 | 'https://www.googleapis.com/userinfo/v2/me').json() | |
39 | ||
40 | print(profile_info) | |
41 | # {'name': '...', 'email': '...', ...} | |
48 | 42 | |
49 | 43 | .. _requests-oauthlib: http://requests-oauthlib.readthedocs.io/en/stable/ |
50 | 44 | .. _OAuth 2.0 Authorization Flow: |
51 | 45 | https://tools.ietf.org/html/rfc6749#section-1.2 |
46 | .. _Using OAuth 2.0 to Access Google APIs: | |
47 | https://developers.google.com/identity/protocols/oauth2 | |
48 | ||
52 | 49 | """ |
53 | 50 | from base64 import urlsafe_b64encode |
54 | 51 | import hashlib |
55 | 52 | import json |
56 | 53 | import logging |
54 | import warnings | |
57 | 55 | |
58 | 56 | try: |
59 | 57 | from secrets import SystemRandom |
66 | 64 | |
67 | 65 | import google.auth.transport.requests |
68 | 66 | import google.oauth2.credentials |
69 | from six.moves import input | |
70 | 67 | |
71 | 68 | import google_auth_oauthlib.helpers |
72 | 69 | |
73 | 70 | |
74 | 71 | _LOGGER = logging.getLogger(__name__) |
72 | _OOB_REDIRECT_URIS = [ | |
73 | "urn:ietf:wg:oauth:2.0:oob", | |
74 | "urn:ietf:wg:oauth:2.0:oob:auto", | |
75 | "oob", | |
76 | ] | |
75 | 77 | |
76 | 78 | |
77 | 79 | class Flow(object): |
87 | 89 | from the `Google API Console`_. |
88 | 90 | |
89 | 91 | .. _client secrets file: |
90 | https://developers.google.com/identity/protocols/OAuth2WebServer | |
92 | https://developers.google.com/identity/protocols/oauth2/web-server | |
91 | 93 | #creatingcred |
92 | 94 | .. _Google API Console: |
93 | 95 | https://console.developers.google.com/apis/credentials |
118 | 120 | autogenerate_code_verifier (bool): If true, auto-generate a |
119 | 121 | code_verifier. |
120 | 122 | .. _client secrets: |
121 | https://developers.google.com/api-client-library/python/guide | |
122 | /aaa_client_secrets | |
123 | https://github.com/googleapis/google-api-python-client/blob | |
124 | /main/docs/client-secrets.md | |
123 | 125 | """ |
124 | 126 | self.client_type = client_type |
125 | 127 | """str: The client type, either ``'web'`` or ``'installed'``""" |
152 | 154 | format. |
153 | 155 | |
154 | 156 | .. _client secrets: |
155 | https://developers.google.com/api-client-library/python/guide | |
156 | /aaa_client_secrets | |
157 | https://github.com/googleapis/google-api-python-client/blob/main/docs/client-secrets.md | |
157 | 158 | """ |
158 | 159 | if "web" in client_config: |
159 | 160 | client_type = "web" |
212 | 213 | |
213 | 214 | @redirect_uri.setter |
214 | 215 | def redirect_uri(self, value): |
216 | if value in _OOB_REDIRECT_URIS: | |
217 | warnings.warn( | |
218 | "'{}' is an OOB redirect URI. The OAuth out-of-band (OOB) flow is deprecated. " | |
219 | "New clients will be unable to use this flow starting on Feb 28, 2022. " | |
220 | "This flow will be deprecated for all clients on Oct 3, 2022. " | |
221 | "Migrate to an alternative flow. " | |
222 | "See https://developers.googleblog.com/2022/02/making-oauth-flows-safer.html?m=1#disallowed-oob".format( | |
223 | value | |
224 | ), | |
225 | DeprecationWarning, | |
226 | ) | |
215 | 227 | self.oauth2session.redirect_uri = value |
216 | 228 | |
217 | 229 | def authorization_url(self, **kwargs): |
326 | 338 | local development or applications that are installed on a desktop operating |
327 | 339 | system. |
328 | 340 | |
329 | This flow has two strategies: The console strategy provided by | |
330 | :meth:`run_console` and the local server strategy provided by | |
331 | :meth:`run_local_server`. | |
341 | This flow uses a local server strategy provided by :meth:`run_local_server`. | |
332 | 342 | |
333 | 343 | Example:: |
334 | 344 | |
349 | 359 | # {'name': '...', 'email': '...', ...} |
350 | 360 | |
351 | 361 | |
352 | Note that these aren't the only two ways to accomplish the installed | |
353 | application flow, they are just the most common ways. You can use the | |
362 | Note that this isn't the only way to accomplish the installed | |
363 | application flow, just one of the most common. You can use the | |
354 | 364 | :class:`Flow` class to perform the same flow with different methods of |
355 | 365 | presenting the authorization URL to the user or obtaining the authorization |
356 | 366 | response, such as using an embedded web view. |
357 | 367 | |
358 | 368 | .. _Installed Application Authorization Flow: |
359 | https://developers.google.com/api-client-library/python/auth | |
360 | /installed-app | |
369 | https://github.com/googleapis/google-api-python-client/blob/main/docs/oauth-installed.md | |
361 | 370 | """ |
362 | 371 | |
363 | 372 | _OOB_REDIRECT_URI = "urn:ietf:wg:oauth:2.0:oob" |
383 | 392 | ): |
384 | 393 | """Run the flow using the console strategy. |
385 | 394 | |
395 | .. deprecated:: 0.5.0 | |
396 | Use :meth:`run_local_server` instead. | |
397 | ||
398 | The OAuth out-of-band (OOB) flow is deprecated. New clients will be unable to | |
399 | use this flow starting on Feb 28, 2022. This flow will be deprecated | |
400 | for all clients on Oct 3, 2022. Migrate to an alternative flow. | |
401 | ||
402 | See https://developers.googleblog.com/2022/02/making-oauth-flows-safer.html?m=1#disallowed-oob" | |
403 | ||
386 | 404 | The console strategy instructs the user to open the authorization URL |
387 | 405 | in their browser. Once the authorization is complete the authorization |
388 | 406 | server will give the user a code. The user then must copy & paste this |
401 | 419 | for the user. |
402 | 420 | """ |
403 | 421 | kwargs.setdefault("prompt", "consent") |
422 | warnings.warn( | |
423 | "New clients will be unable to use `InstalledAppFlow.run_console` " | |
424 | "starting on Feb 28, 2022. All clients will be unable to use this method starting on Oct 3, 2022. " | |
425 | "Use `InstalledAppFlow.run_local_server` instead. For details on the OOB flow deprecation, " | |
426 | "see https://developers.googleblog.com/2022/02/making-oauth-flows-safer.html?m=1#disallowed-oob", | |
427 | DeprecationWarning, | |
428 | ) | |
404 | 429 | |
405 | 430 | self.redirect_uri = self._OOB_REDIRECT_URI |
406 | 431 | |
421 | 446 | authorization_prompt_message=_DEFAULT_AUTH_PROMPT_MESSAGE, |
422 | 447 | success_message=_DEFAULT_WEB_SUCCESS_MESSAGE, |
423 | 448 | open_browser=True, |
449 | redirect_uri_trailing_slash=True, | |
424 | 450 | **kwargs |
425 | 451 | ): |
426 | 452 | """Run the flow using the server strategy. |
443 | 469 | the authorization flow is complete. |
444 | 470 | open_browser (bool): Whether or not to open the authorization URL |
445 | 471 | in the user's browser. |
472 | redirect_uri_trailing_slash (bool): whether or not to add trailing | |
473 | slash when constructing the redirect_uri. Default value is True. | |
446 | 474 | kwargs: Additional keyword arguments passed through to |
447 | 475 | :meth:`authorization_url`. |
448 | 476 | |
457 | 485 | host, port, wsgi_app, handler_class=_WSGIRequestHandler |
458 | 486 | ) |
459 | 487 | |
460 | self.redirect_uri = "http://{}:{}/".format(host, local_server.server_port) | |
488 | redirect_uri_format = ( | |
489 | "http://{}:{}/" if redirect_uri_trailing_slash else "http://{}:{}" | |
490 | ) | |
491 | self.redirect_uri = redirect_uri_format.format(host, local_server.server_port) | |
461 | 492 | auth_url, _ = self.authorization_url(**kwargs) |
462 | 493 | |
463 | 494 | if open_browser: |
516 | 547 | Returns: |
517 | 548 | Iterable[bytes]: The response body. |
518 | 549 | """ |
519 | start_response("200 OK", [("Content-type", "text/plain")]) | |
550 | start_response("200 OK", [("Content-type", "text/plain; charset=utf-8")]) | |
520 | 551 | self.last_request_uri = wsgiref.util.request_uri(environ) |
521 | 552 | return [self._success_message.encode("utf-8")] |
50 | 50 | oauthlib session and the validated client configuration. |
51 | 51 | |
52 | 52 | .. _client secrets: |
53 | https://developers.google.com/api-client-library/python/guide | |
54 | /aaa_client_secrets | |
53 | https://github.com/googleapis/google-api-python-client/blob/main/docs/client-secrets.md | |
55 | 54 | """ |
56 | 55 | |
57 | 56 | if "web" in client_config: |
88 | 87 | oauthlib session and the validated client configuration. |
89 | 88 | |
90 | 89 | .. _client secrets: |
91 | https://developers.google.com/api-client-library/python/guide | |
92 | /aaa_client_secrets | |
90 | https://github.com/googleapis/google-api-python-client/blob/main/docs/client-secrets.md | |
93 | 91 | """ |
94 | 92 | with open(client_secrets_file, "r") as json_file: |
95 | 93 | client_config = json.load(json_file) |
0 | 0 | Metadata-Version: 2.1 |
1 | 1 | Name: google-auth-oauthlib |
2 | Version: 0.4.2 | |
2 | Version: 0.5.0 | |
3 | 3 | Summary: Google Authentication Library |
4 | 4 | Home-page: https://github.com/GoogleCloudPlatform/google-auth-library-python-oauthlib |
5 | 5 | Author: Google Cloud Platform |
6 | 6 | Author-email: jonwayne+google-auth@google.com |
7 | 7 | License: Apache 2.0 |
8 | Description: oauthlib integration for Google Auth | |
9 | ==================================== | |
10 | ||
11 | |pypi| | |
12 | ||
13 | This library provides `oauthlib`_ integration with `google-auth`_. | |
14 | ||
15 | .. |build| image:: https://travis-ci.org/googleapis/google-auth-library-python-oauthlib.svg?branch=master | |
16 | :target: https://travis-ci.org/googleapis/google-auth-library-python-oauthlib | |
17 | .. |docs| image:: https://readthedocs.org/projects/google-auth-oauthlib/badge/?version=latest | |
18 | :target: https://google-auth-oauthlib.readthedocs.io/en/latest/ | |
19 | .. |pypi| image:: https://img.shields.io/pypi/v/google-auth-oauthlib.svg | |
20 | :target: https://pypi.python.org/pypi/google-auth-oauthlib | |
21 | ||
22 | .. _oauthlib: https://github.com/idan/oauthlib | |
23 | .. _google-auth: https://github.com/googleapis/google-auth-library-python | |
24 | ||
25 | Installing | |
26 | ---------- | |
27 | ||
28 | You can install using `pip`_:: | |
29 | ||
30 | $ pip install google-auth-oauthlib | |
31 | ||
32 | .. _pip: https://pip.pypa.io/en/stable/ | |
33 | ||
34 | Documentation | |
35 | ------------- | |
36 | ||
37 | The latest documentation is available at `google-auth-oauthlib.readthedocs.io`_. | |
38 | ||
39 | .. _google-auth-oauthlib.readthedocs.io: http://google-auth-oauthlib.readthedocs.io/ | |
40 | ||
41 | License | |
42 | ------- | |
43 | ||
44 | Apache 2.0 - See `the LICENSE`_ for more information. | |
45 | ||
46 | .. _the LICENSE: https://github.com/googleapis/google-auth-library-python-oauthlib/blob/master/LICENSE | |
47 | ||
48 | 8 | Keywords: google auth oauth client oauthlib |
49 | 9 | Platform: UNKNOWN |
50 | 10 | Classifier: Programming Language :: Python :: 3 |
52 | 12 | Classifier: Programming Language :: Python :: 3.7 |
53 | 13 | Classifier: Programming Language :: Python :: 3.8 |
54 | 14 | Classifier: Programming Language :: Python :: 3.9 |
15 | Classifier: Programming Language :: Python :: 3.10 | |
55 | 16 | Classifier: Development Status :: 3 - Alpha |
56 | 17 | Classifier: Intended Audience :: Developers |
57 | 18 | Classifier: License :: OSI Approved :: Apache Software License |
62 | 23 | Classifier: Topic :: Internet :: WWW/HTTP |
63 | 24 | Requires-Python: >=3.6 |
64 | 25 | Provides-Extra: tool |
26 | License-File: LICENSE | |
27 | ||
28 | oauthlib integration for Google Auth | |
29 | ==================================== | |
30 | ||
31 | |pypi| | |
32 | ||
33 | This library provides `oauthlib`_ integration with `google-auth`_. | |
34 | ||
35 | .. |build| image:: https://travis-ci.org/googleapis/google-auth-library-python-oauthlib.svg?branch=main | |
36 | :target: https://travis-ci.org/googleapis/google-auth-library-python-oauthlib | |
37 | .. |docs| image:: https://readthedocs.org/projects/google-auth-oauthlib/badge/?version=latest | |
38 | :target: https://google-auth-oauthlib.readthedocs.io/en/latest/ | |
39 | .. |pypi| image:: https://img.shields.io/pypi/v/google-auth-oauthlib.svg | |
40 | :target: https://pypi.python.org/pypi/google-auth-oauthlib | |
41 | ||
42 | .. _oauthlib: https://github.com/idan/oauthlib | |
43 | .. _google-auth: https://github.com/googleapis/google-auth-library-python | |
44 | ||
45 | Installing | |
46 | ---------- | |
47 | ||
48 | You can install using `pip`_:: | |
49 | ||
50 | $ pip install google-auth-oauthlib | |
51 | ||
52 | .. _pip: https://pip.pypa.io/en/stable/ | |
53 | ||
54 | Documentation | |
55 | ------------- | |
56 | ||
57 | The latest documentation is available at `google-auth-oauthlib.readthedocs.io`_. | |
58 | ||
59 | .. _google-auth-oauthlib.readthedocs.io: http://google-auth-oauthlib.readthedocs.io/ | |
60 | ||
61 | Supported Python Versions | |
62 | ------------------------- | |
63 | Python >= 3.6 | |
64 | ||
65 | ||
66 | Unsupported Python Versions | |
67 | --------------------------- | |
68 | ||
69 | Python == 2.7, Python == 3.5. | |
70 | ||
71 | The last version of this library compatible with Python 2.7 and 3.5 is | |
72 | `google-auth-oauthlib==0.4.1`. | |
73 | ||
74 | License | |
75 | ------- | |
76 | ||
77 | Apache 2.0 - See `the LICENSE`_ for more information. | |
78 | ||
79 | .. _the LICENSE: https://github.com/googleapis/google-auth-library-python-oauthlib/blob/main/LICENSE | |
80 | ||
81 |
17 | 17 | from setuptools import setup |
18 | 18 | |
19 | 19 | |
20 | TOOL_DEPENDENCIES = "click" | |
20 | TOOL_DEPENDENCIES = "click>=6.0.0" | |
21 | 21 | |
22 | DEPENDENCIES = ("google-auth", "requests-oauthlib>=0.7.0") | |
22 | DEPENDENCIES = ("google-auth>=1.0.0", "requests-oauthlib>=0.7.0") | |
23 | 23 | |
24 | 24 | |
25 | 25 | with io.open("README.rst", "r") as fh: |
26 | 26 | long_description = fh.read() |
27 | 27 | |
28 | 28 | |
29 | version = "0.4.2" | |
29 | version = "0.5.0" | |
30 | 30 | |
31 | 31 | setup( |
32 | 32 | name="google-auth-oauthlib", |
53 | 53 | "Programming Language :: Python :: 3.7", |
54 | 54 | "Programming Language :: Python :: 3.8", |
55 | 55 | "Programming Language :: Python :: 3.9", |
56 | "Programming Language :: Python :: 3.10", | |
56 | 57 | "Development Status :: 3 - Alpha", |
57 | 58 | "Intended Audience :: Developers", |
58 | 59 | "License :: OSI Approved :: Apache Software License", |
23 | 23 | import mock |
24 | 24 | import pytest |
25 | 25 | import requests |
26 | from six.moves import urllib | |
26 | import urllib | |
27 | 27 | |
28 | 28 | from google_auth_oauthlib import flow |
29 | 29 | |
55 | 55 | instance.redirect_uri |
56 | 56 | == instance.oauth2session.redirect_uri |
57 | 57 | == mock.sentinel.redirect_uri |
58 | ) | |
59 | ||
60 | def test_from_client_secrets_file_with_oob_redirect_uri(self): | |
61 | with pytest.deprecated_call(): | |
62 | instance = flow.Flow.from_client_secrets_file( | |
63 | CLIENT_SECRETS_FILE, | |
64 | scopes=mock.sentinel.scopes, | |
65 | redirect_uri="urn:ietf:wg:oauth:2.0:oob", | |
66 | ) | |
67 | ||
68 | assert ( | |
69 | instance.redirect_uri | |
70 | == instance.oauth2session.redirect_uri | |
71 | == "urn:ietf:wg:oauth:2.0:oob" | |
58 | 72 | ) |
59 | 73 | |
60 | 74 | def test_from_client_config_installed(self): |
281 | 295 | with fetch_token_patch as fetch_token_mock: |
282 | 296 | yield fetch_token_mock |
283 | 297 | |
284 | @mock.patch("google_auth_oauthlib.flow.input", autospec=True) | |
298 | @mock.patch("builtins.input", autospec=True) | |
285 | 299 | def test_run_console(self, input_mock, instance, mock_fetch_token): |
286 | 300 | input_mock.return_value = mock.sentinel.code |
287 | 301 | instance.code_verifier = "amanaplanacanalpanama" |
288 | credentials = instance.run_console() | |
302 | ||
303 | with pytest.deprecated_call(): | |
304 | credentials = instance.run_console() | |
289 | 305 | |
290 | 306 | assert credentials.token == mock.sentinel.access_token |
291 | 307 | assert credentials._refresh_token == mock.sentinel.refresh_token |
320 | 336 | assert credentials._refresh_token == mock.sentinel.refresh_token |
321 | 337 | assert credentials.id_token == mock.sentinel.id_token |
322 | 338 | assert webbrowser_mock.open.called |
339 | assert instance.redirect_uri == f"http://localhost:{port}/" | |
323 | 340 | |
324 | 341 | expected_auth_response = auth_redirect_url.replace("http", "https") |
325 | 342 | mock_fetch_token.assert_called_with( |
340 | 357 | instance.code_verifier = "amanaplanacanalpanama" |
341 | 358 | |
342 | 359 | with concurrent.futures.ThreadPoolExecutor(max_workers=1) as pool: |
343 | future = pool.submit(partial(instance.run_local_server, port=port)) | |
360 | future = pool.submit( | |
361 | partial( | |
362 | instance.run_local_server, | |
363 | port=port, | |
364 | redirect_uri_trailing_slash=False, | |
365 | ) | |
366 | ) | |
344 | 367 | |
345 | 368 | while not future.done(): |
346 | 369 | try: |
354 | 377 | assert credentials._refresh_token == mock.sentinel.refresh_token |
355 | 378 | assert credentials.id_token == mock.sentinel.id_token |
356 | 379 | assert webbrowser_mock.open.called |
380 | assert instance.redirect_uri == f"http://localhost:{port}" | |
357 | 381 | |
358 | 382 | expected_auth_response = auth_redirect_url.replace("http", "https") |
359 | 383 | mock_fetch_token.assert_called_with( |