Import upstream version 0.4.6+git20210901.1.fc7023c
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.4.6 | |
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 |
12 | 12 | |
13 | 13 | This library provides `oauthlib`_ integration with `google-auth`_. |
14 | 14 | |
15 | .. |build| image:: https://travis-ci.org/googleapis/google-auth-library-python-oauthlib.svg?branch=master | |
15 | .. |build| image:: https://travis-ci.org/googleapis/google-auth-library-python-oauthlib.svg?branch=main | |
16 | 16 | :target: https://travis-ci.org/googleapis/google-auth-library-python-oauthlib |
17 | 17 | .. |docs| image:: https://readthedocs.org/projects/google-auth-oauthlib/badge/?version=latest |
18 | 18 | :target: https://google-auth-oauthlib.readthedocs.io/en/latest/ |
38 | 38 | |
39 | 39 | .. _google-auth-oauthlib.readthedocs.io: http://google-auth-oauthlib.readthedocs.io/ |
40 | 40 | |
41 | Supported Python Versions | |
42 | ------------------------- | |
43 | Python >= 3.6 | |
44 | ||
45 | ||
46 | Unsupported Python Versions | |
47 | --------------------------- | |
48 | ||
49 | Python == 2.7, Python == 3.5. | |
50 | ||
51 | The last version of this library compatible with Python 2.7 and 3.5 is | |
52 | `google-auth-oauthlib==0.4.1`. | |
53 | ||
41 | 54 | License |
42 | 55 | ------- |
43 | 56 | |
44 | 57 | Apache 2.0 - See `the LICENSE`_ for more information. |
45 | 58 | |
46 | .. _the LICENSE: https://github.com/googleapis/google-auth-library-python-oauthlib/blob/master/LICENSE | |
59 | .. _the LICENSE: https://github.com/googleapis/google-auth-library-python-oauthlib/blob/main/LICENSE | |
47 | 60 | |
48 | 61 | Keywords: google auth oauth client oauthlib |
49 | 62 | Platform: UNKNOWN |
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 |
66 | 66 | |
67 | 67 | import google.auth.transport.requests |
68 | 68 | import google.oauth2.credentials |
69 | from six.moves import input | |
70 | 69 | |
71 | 70 | import google_auth_oauthlib.helpers |
72 | 71 | |
87 | 86 | from the `Google API Console`_. |
88 | 87 | |
89 | 88 | .. _client secrets file: |
90 | https://developers.google.com/identity/protocols/OAuth2WebServer | |
89 | https://developers.google.com/identity/protocols/oauth2/web-server | |
91 | 90 | #creatingcred |
92 | 91 | .. _Google API Console: |
93 | 92 | https://console.developers.google.com/apis/credentials |
118 | 117 | autogenerate_code_verifier (bool): If true, auto-generate a |
119 | 118 | code_verifier. |
120 | 119 | .. _client secrets: |
121 | https://developers.google.com/api-client-library/python/guide | |
122 | /aaa_client_secrets | |
120 | https://github.com/googleapis/google-api-python-client/blob | |
121 | /main/docs/client-secrets.md | |
123 | 122 | """ |
124 | 123 | self.client_type = client_type |
125 | 124 | """str: The client type, either ``'web'`` or ``'installed'``""" |
152 | 151 | format. |
153 | 152 | |
154 | 153 | .. _client secrets: |
155 | https://developers.google.com/api-client-library/python/guide | |
156 | /aaa_client_secrets | |
154 | https://github.com/googleapis/google-api-python-client/blob/main/docs/client-secrets.md | |
157 | 155 | """ |
158 | 156 | if "web" in client_config: |
159 | 157 | client_type = "web" |
356 | 354 | response, such as using an embedded web view. |
357 | 355 | |
358 | 356 | .. _Installed Application Authorization Flow: |
359 | https://developers.google.com/api-client-library/python/auth | |
360 | /installed-app | |
357 | https://github.com/googleapis/google-api-python-client/blob/main/docs/oauth-installed.md | |
361 | 358 | """ |
362 | 359 | |
363 | 360 | _OOB_REDIRECT_URI = "urn:ietf:wg:oauth:2.0:oob" |
421 | 418 | authorization_prompt_message=_DEFAULT_AUTH_PROMPT_MESSAGE, |
422 | 419 | success_message=_DEFAULT_WEB_SUCCESS_MESSAGE, |
423 | 420 | open_browser=True, |
421 | redirect_uri_trailing_slash=True, | |
424 | 422 | **kwargs |
425 | 423 | ): |
426 | 424 | """Run the flow using the server strategy. |
443 | 441 | the authorization flow is complete. |
444 | 442 | open_browser (bool): Whether or not to open the authorization URL |
445 | 443 | in the user's browser. |
444 | redirect_uri_trailing_slash (bool): whether or not to add trailing | |
445 | slash when constructing the redirect_uri. Default value is True. | |
446 | 446 | kwargs: Additional keyword arguments passed through to |
447 | 447 | :meth:`authorization_url`. |
448 | 448 | |
457 | 457 | host, port, wsgi_app, handler_class=_WSGIRequestHandler |
458 | 458 | ) |
459 | 459 | |
460 | self.redirect_uri = "http://{}:{}/".format(host, local_server.server_port) | |
460 | redirect_uri_format = ( | |
461 | "http://{}:{}/" if redirect_uri_trailing_slash else "http://{}:{}" | |
462 | ) | |
463 | self.redirect_uri = redirect_uri_format.format(host, local_server.server_port) | |
461 | 464 | auth_url, _ = self.authorization_url(**kwargs) |
462 | 465 | |
463 | 466 | if open_browser: |
516 | 519 | Returns: |
517 | 520 | Iterable[bytes]: The response body. |
518 | 521 | """ |
519 | start_response("200 OK", [("Content-type", "text/plain")]) | |
522 | start_response("200 OK", [("Content-type", "text/plain; charset=utf-8")]) | |
520 | 523 | self.last_request_uri = wsgiref.util.request_uri(environ) |
521 | 524 | 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.4.6 | |
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 |
12 | 12 | |
13 | 13 | This library provides `oauthlib`_ integration with `google-auth`_. |
14 | 14 | |
15 | .. |build| image:: https://travis-ci.org/googleapis/google-auth-library-python-oauthlib.svg?branch=master | |
15 | .. |build| image:: https://travis-ci.org/googleapis/google-auth-library-python-oauthlib.svg?branch=main | |
16 | 16 | :target: https://travis-ci.org/googleapis/google-auth-library-python-oauthlib |
17 | 17 | .. |docs| image:: https://readthedocs.org/projects/google-auth-oauthlib/badge/?version=latest |
18 | 18 | :target: https://google-auth-oauthlib.readthedocs.io/en/latest/ |
38 | 38 | |
39 | 39 | .. _google-auth-oauthlib.readthedocs.io: http://google-auth-oauthlib.readthedocs.io/ |
40 | 40 | |
41 | Supported Python Versions | |
42 | ------------------------- | |
43 | Python >= 3.6 | |
44 | ||
45 | ||
46 | Unsupported Python Versions | |
47 | --------------------------- | |
48 | ||
49 | Python == 2.7, Python == 3.5. | |
50 | ||
51 | The last version of this library compatible with Python 2.7 and 3.5 is | |
52 | `google-auth-oauthlib==0.4.1`. | |
53 | ||
41 | 54 | License |
42 | 55 | ------- |
43 | 56 | |
44 | 57 | Apache 2.0 - See `the LICENSE`_ for more information. |
45 | 58 | |
46 | .. _the LICENSE: https://github.com/googleapis/google-auth-library-python-oauthlib/blob/master/LICENSE | |
59 | .. _the LICENSE: https://github.com/googleapis/google-auth-library-python-oauthlib/blob/main/LICENSE | |
47 | 60 | |
48 | 61 | Keywords: google auth oauth client oauthlib |
49 | 62 | Platform: UNKNOWN |
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.4.6" | |
30 | 30 | |
31 | 31 | setup( |
32 | 32 | name="google-auth-oauthlib", |
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 | |
281 | 281 | with fetch_token_patch as fetch_token_mock: |
282 | 282 | yield fetch_token_mock |
283 | 283 | |
284 | @mock.patch("google_auth_oauthlib.flow.input", autospec=True) | |
284 | @mock.patch("builtins.input", autospec=True) | |
285 | 285 | def test_run_console(self, input_mock, instance, mock_fetch_token): |
286 | 286 | input_mock.return_value = mock.sentinel.code |
287 | 287 | instance.code_verifier = "amanaplanacanalpanama" |
320 | 320 | assert credentials._refresh_token == mock.sentinel.refresh_token |
321 | 321 | assert credentials.id_token == mock.sentinel.id_token |
322 | 322 | assert webbrowser_mock.open.called |
323 | assert instance.redirect_uri == f"http://localhost:{port}/" | |
323 | 324 | |
324 | 325 | expected_auth_response = auth_redirect_url.replace("http", "https") |
325 | 326 | mock_fetch_token.assert_called_with( |
340 | 341 | instance.code_verifier = "amanaplanacanalpanama" |
341 | 342 | |
342 | 343 | with concurrent.futures.ThreadPoolExecutor(max_workers=1) as pool: |
343 | future = pool.submit(partial(instance.run_local_server, port=port)) | |
344 | future = pool.submit( | |
345 | partial( | |
346 | instance.run_local_server, | |
347 | port=port, | |
348 | redirect_uri_trailing_slash=False, | |
349 | ) | |
350 | ) | |
344 | 351 | |
345 | 352 | while not future.done(): |
346 | 353 | try: |
354 | 361 | assert credentials._refresh_token == mock.sentinel.refresh_token |
355 | 362 | assert credentials.id_token == mock.sentinel.id_token |
356 | 363 | assert webbrowser_mock.open.called |
364 | assert instance.redirect_uri == f"http://localhost:{port}" | |
357 | 365 | |
358 | 366 | expected_auth_response = auth_redirect_url.replace("http", "https") |
359 | 367 | mock_fetch_token.assert_called_with( |