Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Spanner] authentication issues should result in a user error #4

Closed
@jeanbza

Description

@jeanbza
  1. Copy paste code from https://cloud.google.com/spanner/docs/getting-started/python/
  2. Run

... it hangs forever

  1. Waste Spend hour struggling to figure out what is happening.

  2. Figure out how to turn on http logging with,

    import logging
    
    logging.basicConfig(level=logging.DEBUG)
    
  3. See:

    DEBUG:google.auth.transport.requests:Making request: POST https://oauth2.googleapis.com/token
    DEBUG:urllib3.connectionpool:https://oauth2.googleapis.com:443 "POST /token HTTP/1.1" 400 None
    ERROR:grpc._plugin_wrapping:AuthMetadataPluginCallback "<google.auth.transport.grpc.AuthMetadataPlugin object at 0x10d79d4a8>" raised exception!
    Traceback (most recent call last):
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/grpc/_plugin_wrapping.py", line 79, in __call__
        callback_state, callback))
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/google/auth/transport/grpc.py", line 77, in __call__
        callback(self._get_authorization_headers(context), None)
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/google/auth/transport/grpc.py", line 65, in _get_authorization_headers
        headers)
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/google/auth/credentials.py", line 122, in before_request
        self.refresh(request)
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/google/oauth2/service_account.py", line 322, in refresh
        request, self._token_uri, assertion)
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/google/oauth2/_client.py", line 145, in jwt_grant
        response_data = _token_endpoint_request(request, token_uri, body)
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/google/oauth2/_client.py", line 111, in _token_endpoint_request
        _handle_error_response(response_body)
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/google/oauth2/_client.py", line 61, in _handle_error_response
        error_details, response_body)
    google.auth.exceptions.RefreshError: ('invalid_grant: Not a valid email or user ID.', '{\n  "error": "invalid_grant",\n  "error_description": "Not a valid email or user ID."\n}')
    DEBUG:google.api_core.retry:Retrying due to 503 Getting metadata from plugin failed with error: ('invalid_grant: Not a valid email or user ID.', '{\n  "error": "invalid_grant",\n  "error_description": "Not a valid email or user ID."\n}'), sleeping 1.3s ...
    

This is an error that will never resolve. We should surface it to the user immediately.

Also: I have no idea why this is a 503 UNAVAILABLE. Why would it not be a 400 BAD REQUEST or 401 UNAUTHORIZED??

Metadata

Metadata

Assignees

Labels

🚨This issue needs some love.api: spannerIssues related to the googleapis/python-spanner API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions