-
Notifications
You must be signed in to change notification settings - Fork 27
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
Allow username and password to be passed to Connection object #16
Comments
As far as I know, support has been dropped for username/password authentication in favor of API tokens in Dataverse 4.0 (see http://guides.dataverse.org/en/latest/api/sword.html#backward-incompatible-changes). The client in its current state is very 3.X incompatible, but I could point you to the last 3.6 compatible commit that still accepted usernames/passwords if you are trying to work with an older installation. |
Actually I was referring more to the new native API which allows one to get the API token from the username and password. This could happen seamlessly inside the Connection object, right? In my mini-Python library I do: LOGIN_URL = "https://{server}/api/builtin-users/{username}/api-token?password={password}"
class Connection(object):
def __init__(self, username=None, password=None, api_token=None, server=None):
self.server = server
self.username = username
if username is not None:
if password is None:
raise ValueError("password is not set")
url = LOGIN_URL.format(server=server, username=username, password=password)
response = requests.get(url).json()
self.api_token = parse_response(response)['message']
else:
self.api_token = api_token |
Yeah, that works. The only issue that could come up is that currently, you have to generate the API token through the GUI before you can retrieve it through the API, but with good error handling that shouldn't be a problem. If this is something you would use, feel free to open a PR. |
Right. See also IQSS/dataverse#1935 |
... as an alternative to the API token. I can try and open a pull request if you like.
The text was updated successfully, but these errors were encountered: