Skip to content

SwordApi Authentications fails and get_service_document throws error #162

@jmurugan-fzj

Description

@jmurugan-fzj

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    status:incomingNewly created issue to be forwarded

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions