quickstart.py fails when Firefox is default browser on Mac

Đang mở
#160 1 bình luận 4 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
25/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
authentication

Hướng nghiên cứu

The failure starts at flow.run_local_server(port=0) in quickstart.py, line 33, and the traceback runs through google_auth_oauthlib/flow.py into oauthlib's parameters.py, where MismatchingStateError is raised. Reproduce with Firefox as the default browser on macOS, then check whether the state value is lost or altered on the localhost redirect. Done means either a working sample under Firefox or a documented workaround.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Expected Behavior

Please visit this URL to authorize this application: https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=xxx.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A63472%2F&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fgmail.readonly&state=xxx&access_type=offline

Then browser opens URL and user authenticates to account then token.pickle gets created and the following gets displayed

Labels:
CHAT
SENT
INBOX
IMPORTANT
TRASH
DRAFT
SPAM
CATEGORY_FORUMS
CATEGORY_UPDATES
CATEGORY_PERSONAL
CATEGORY_PROMOTIONS
CATEGORY_SOCIAL
STARRED
UNREAD

Actual Behavior

Please visit this URL to authorize this application: https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=xxx.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A63472%2F&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fgmail.readonly&state=xxx&access_type=offline

Then browser opens URL and user authenticates to account

Traceback (most recent call last):
File "quickstart.py", line 53, in
main()
File "quickstart.py", line 33, in main
creds = flow.run_local_server(port=0)
File "/Users/username/.virtualenvs/bpaml-email/lib/python3.8/site-packages/google_auth_oauthlib/flow.py", line 460, in run_local_server
self.fetch_token(authorization_response=authorization_response)
File "/Users/username/.virtualenvs/bpaml-email/lib/python3.8/site-packages/google_auth_oauthlib/flow.py", line 280, in fetch_token
return self.oauth2session.fetch_token(
File "/Users/username/.virtualenvs/bpaml-email/lib/python3.8/site-packages/requests_oauthlib/oauth2_session.py", line 239, in fetch_token
self._client.parse_request_uri_response(
File "/Users/username/.virtualenvs/bpaml-email/lib/python3.8/site-packages/oauthlib/oauth2/rfc6749/clients/web_application.py", line 203, in parse_request_uri_response
response = parse_authorization_code_response(uri, state=state)
File "/Users/username/.virtualenvs/bpaml-email/lib/python3.8/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 268, in parse_authorization_code_response
raise MismatchingStateError()
oauthlib.oauth2.rfc6749.errors.MismatchingStateError: (mismatching_state) CSRF Warning! State not equal in request and response.

token.pickle file is not created

Steps to Reproduce the Problem

  1. Set Firefox as default browser
  2. python3 quickstart.py

Specifications

  • Python version (python --version) Python 3.8.2
  • OS (Mac 10.14.6)
  • Firefox 76.0.1

Setting the default browser to Safari or Google Chrome achieved the expected behaviour

Ngôn ngữ chính
Python
Star
1.4k
Fork
917
Merge trung bình
3 phút
Pull request đã merge (30 ngày)
1

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của googleworkspace/python-samples

Tất cả issue của googleworkspace/python-samples

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.