Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Token support in gripql python client #190

Merged
merged 16 commits into from
Mar 11, 2019
Merged

Conversation

adamstruck
Copy link
Contributor

closes #178

@adamstruck
Copy link
Contributor Author

I still need to test this more extensively.

@kellrott
Copy link
Member

kellrott commented Mar 6, 2019

If I try a query with no auth, I get the exception stack:

Traceback (most recent call last):
  File "test.py", line 5, in <module>
    print(conn.listGraphs())
  File "/Users/ellrott/workspaces/grip/venv/lib/python3.7/site-packages/gripql-0.2.0-py3.7.egg/gripql/connection.py", line 23, in listGraphs
  File "/Users/ellrott/workspaces/grip/venv/lib/python3.7/site-packages/requests/models.py", line 897, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/__init__.py", line 348, in loads
    return _default_decoder.decode(s)
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 2 column 1 (char 1)

Which is not descriptive enough to let me know that I'm having an auth problem.

@kellrott kellrott mentioned this pull request Mar 6, 2019
@bwalsh
Copy link
Collaborator

bwalsh commented Mar 7, 2019

@adamstruck @kellrott

elif response.status_code == 302 and 'oauth2' in response.headers.get('Location',None):
  http_error_msg = '%s Server Error: %s for url: %s response: %s Please visit %s to authenticate.' % (
            response.status_code, reason,
            response.url, rsp_body, response.headers['Location']
        )  

Should produce:

u'302 Server Error: Moved Temporarily for url: https://bmeg-staging6.ddns.net/api/v1/graph response: <html>\r\n<head><title>302 Found</title></head>\r\n<body bgcolor="white">\r\n<center><h1>302 Found</h1></center>\r\n<hr><center>nginx/1.10.3</center>\r\n</body>\r\n</html>\r\n Please visit https://accounts.google.com/o/oauth2/auth?scope=email&client_id=340847348510-t4olm7pavc7sjgtdqu1hpaa2au56u4ek.apps.googleusercontent.com&state=https%3A%2F%2Fbmeg-staging6.ddns.net%2Fanalyze%2Faccess&login_hint=&redirect_uri=https%3A%2F%2Fbmeg-staging6.ddns.net%2F_oauth&response_type=code to authenticate.'

I've made an nginx change to always direct the user to /analyze/access in the bmeg-site

bmeg/deployment@31c504c

@adamstruck adamstruck merged commit cf2abe2 into master Mar 11, 2019
@adamstruck adamstruck deleted the gripql-python-oauth branch March 27, 2019 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Python client refactor - duplicated code
3 participants