broadinstitute/fiss

Catch `RefreshError` due to lack of app default credentials

Closed this issue · 1 comments

When a gcloud account has been activated, but application default credentials have not, fiss does the following:

  File "/xchip/tcga/Tools/gdac/gdops_2.0.0/lib/python2.7/site-packages/firecloud/api.py", line 81, in __get
    r = __SESSION.get(urljoin(root_url, methcall), headers=headers, **kwargs)
  File "/xchip/tcga/Tools/gdac/gdops_2.0.0/lib/python2.7/site-packages/requests/sessions.py", line 546, in get
    return self.request('GET', url, **kwargs)
  File "/xchip/tcga/Tools/gdac/gdops_2.0.0/lib/python2.7/site-packages/google/auth/transport/requests.py", line 198, in request
    self._auth_request, method, url, request_headers)
  File "/xchip/tcga/Tools/gdac/gdops_2.0.0/lib/python2.7/site-packages/google/auth/credentials.py", line 122, in before_request
    self.refresh(request)
  File "/xchip/tcga/Tools/gdac/gdops_2.0.0/lib/python2.7/site-packages/google/oauth2/credentials.py", line 136, in refresh
    self._client_secret))
  File "/xchip/tcga/Tools/gdac/gdops_2.0.0/lib/python2.7/site-packages/google/oauth2/_client.py", line 237, in refresh_grant
    response_data = _token_endpoint_request(request, token_uri, body)
  File "/xchip/tcga/Tools/gdac/gdops_2.0.0/lib/python2.7/site-packages/google/oauth2/_client.py", line 111, in _token_endpoint_request
    _handle_error_response(response_body)
  File "/xchip/tcga/Tools/gdac/gdops_2.0.0/lib/python2.7/site-packages/google/oauth2/_client.py", line 61, in _handle_error_response
    error_details, response_body)
RefreshError: ('invalid_grant: Bad Request', u'{\n  "error": "invalid_grant",\n  "error_description": "Bad Request"\n}')

We should catch this and run the app default credentials command when it occurs and retry.

Fixed by #119