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

SwordApi Authentications fails and get_service_document throws error #162

Open
jmurugan-fzj opened this issue Nov 15, 2023 · 3 comments · May be fixed by #163
Open

SwordApi Authentications fails and get_service_document throws error #162

jmurugan-fzj opened this issue Nov 15, 2023 · 3 comments · May be fixed by #163
Labels
status:incoming Newly created issue to be forwarded

Comments

@jmurugan-fzj
Copy link

Steps to reproduce:

  • Install latest version of pydataverse
    image

  • Create an instance of SwordApi and try to get the service document

    api = SwordApi("https://demo.dataverse.org/", api_token="give_a_valid_token")
    test1 = api.get_service_document()
  • API fails with the below given error
    Screenshot from 2023-11-15 11-35-14

Additional info:

  • get_request method within ../pyDataverse/api.py sets api_token in params["key"] which is the reason for the error, see the snippet below from the code base
        params = {}
        params["User-Agent"] = "pydataverse"
        if self.api_token:
            params["key"] = str(self.api_token)

        try:
            resp = get(url, params=params)
  • Instead this should be replaced with basic authentication as given below
        params = {}
        params["User-Agent"] = "pydataverse"
        basic = None
        if self.api_token:
            basic = HTTPBasicAuth(self.api_token, '')

        try:
            resp = get(url, params=params, auth=basic)
@jmurugan-fzj jmurugan-fzj added the status:incoming Newly created issue to be forwarded label Nov 15, 2023
@jmurugan-fzj
Copy link
Author

@skasberger If you could provide me the access, I can also create the pull request immediately, Thanks

@pdurbin
Copy link
Member

pdurbin commented Nov 15, 2023

@jmurugan-fzj hi! Thanks for your interest in contributing! I'm confused, though. You could create a fork and make your pull request from there, right? Maybe I'm missing something. 🤔

@jmurugan-fzj
Copy link
Author

@pdurbin Thanks for the quick response, I have done as suggested and created a PR too: fix(sword-api): get_service_document throws error due to auth-failure, Please take a look and let me know; I am not sure if I can assign any reviewers or change any properties of the PR, just kept it as such!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:incoming Newly created issue to be forwarded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants