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

403 Forbidden error when trying to run dvn_client.py #4

Open
astrofrog opened this issue Mar 31, 2015 · 2 comments
Open

403 Forbidden error when trying to run dvn_client.py #4

astrofrog opened this issue Mar 31, 2015 · 2 comments

Comments

@astrofrog
Copy link

I tried running the example provided in the README for the Python code. I created a new file with:

DEFAULT_USERNAME = ""
DEFAULT_PASSWORD = ""
DEFAULT_HOST = ""
DEFAULT_CERT = "../resources/dvn-build.hmdc.harvard.edu" #see below for info on the cert

then ran:

python dvn_client.py --config config.py --runTests tests.py

but got:

Traceback (most recent call last):
  File "dvn_client.py", line 51, in main
    cert=DEFAULT_CERT)
  File "/Volumes/Raptor/tmp/swordpoc/dvn_client/src/connection.py", line 29, in __init__
    self._connect()
  File "/Volumes/Raptor/tmp/swordpoc/dvn_client/src/connection.py", line 37, in _connect
    self.serviceDocument = self.swordConnection.get_service_document()
  File "/Volumes/Raptor/miniconda3/envs/dataverse/lib/python2.7/site-packages/sword2-0.1-py2.7.egg/sword2/connection.py", line 391, in get_service_document
    resp, content = self.h.request(self.sd_iri, "GET", headers=headers)
  File "/Volumes/Raptor/miniconda3/envs/dataverse/lib/python2.7/site-packages/sword2-0.1-py2.7.egg/sword2/http_layer.py", line 73, in request
    resp, content = self.h.request(uri, method, headers=headers, body=payload)
  File "/Volumes/Raptor/miniconda3/envs/dataverse/lib/python2.7/site-packages/httplib2/__init__.py", line 1441, in request
    (scheme, authority, request_uri, defrag_uri) = urlnorm(uri)
  File "/Volumes/Raptor/miniconda3/envs/dataverse/lib/python2.7/site-packages/httplib2/__init__.py", line 218, in urlnorm
    raise RelativeURIError("Only absolute URIs are allowed. uri = %s" % uri)
RelativeURIError: Only absolute URIs are allowed. uri = https:///dvn/api/data-deposit/v1/swordv2/service-document

Next, I tried setting:

DEFAULT_HOST = "dvn.iq.harvard.edu"

but I then get a 403: Forbidden error:

Traceback (most recent call last):
  File "dvn_client.py", line 51, in main
    cert=DEFAULT_CERT)
  File "/Volumes/Raptor/tmp/swordpoc/dvn_client/src/connection.py", line 29, in __init__
    self._connect()
  File "/Volumes/Raptor/tmp/swordpoc/dvn_client/src/connection.py", line 37, in _connect
    self.serviceDocument = self.swordConnection.get_service_document()
  File "/Volumes/Raptor/miniconda3/envs/dataverse/lib/python2.7/site-packages/sword2-0.1-py2.7.egg/sword2/connection.py", line 391, in get_service_document
    resp, content = self.h.request(self.sd_iri, "GET", headers=headers)
  File "/Volumes/Raptor/miniconda3/envs/dataverse/lib/python2.7/site-packages/sword2-0.1-py2.7.egg/sword2/http_layer.py", line 73, in request
    resp, content = self.h.request(uri, method, headers=headers, body=payload)
  File "/Volumes/Raptor/miniconda3/envs/dataverse/lib/python2.7/site-packages/httplib2/__init__.py", line 1593, in request
    (response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
  File "/Volumes/Raptor/miniconda3/envs/dataverse/lib/python2.7/site-packages/httplib2/__init__.py", line 1335, in _request
    (response, content) = self._conn_request(conn, request_uri, method, body, headers)
  File "/Volumes/Raptor/miniconda3/envs/dataverse/lib/python2.7/site-packages/httplib2/__init__.py", line 1257, in _conn_request
    conn.connect()
  File "/Volumes/Raptor/miniconda3/envs/dataverse/lib/python2.7/site-packages/httplib2/__init__.py", line 1018, in connect
    sock.connect((self.host, self.port))
  File "/Volumes/Raptor/miniconda3/envs/dataverse/lib/python2.7/site-packages/httplib2/socks.py", line 424, in connect
    self.__negotiatehttp(destpair[0], destpair[1])
  File "/Volumes/Raptor/miniconda3/envs/dataverse/lib/python2.7/site-packages/httplib2/socks.py", line 390, in __negotiatehttp
    raise HTTPError((statuscode, statusline[2]))
HTTPError: (403, 'Forbidden')

Finally, I tried putting in my username/password for the dataverse, but the error persists. What am I doing wrong?

@astrofrog
Copy link
Author

If I go to:

https://thedata.harvard.edu/dvn/api/data-deposit/v1/swordv2/service-document

manually and enter my username and password, it downloads the file.

@astrofrog
Copy link
Author

An easier way for me to reproduce the error is:

import sword2

c = sword2.Connection("https://dvn.iq.harvard.edu/dvn/api/data-deposit/v1/swordv2/service-document", 
                      user_name = ".........",
                      user_pass = ".........")

serviceDocument = c.get_service_document()

(removed sensitive login data)

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

No branches or pull requests

1 participant