Closed wiwski closed 4 months ago
I got the same error. I investigated a bit and the problem is that the line 65:
person = response.get("person")
stores the following json
in the person
variable:
{'created-date': {'value': 1684137584077},
'credit-name': None,
'family-name': None,
'given-names': {'value': 'John'},
'last-modified-date': {'value': 1684137584077},
'path': '0000-0000-0000-0000',
'source': None,
'visibility': 'PUBLIC'}
There, the 'family_name'
key is present, however its value can be None
. And by calling the code on line 78:
last_name = name.get("family-name", {}).get("value", "")
the name.get("family-name", {})
evaluates to None
and None
obviously does not have a get()
method. Hence the error.
In ORCID it is mandatory to fill in your first name, thus the given-names
dict should always have a value
key, however, it is not mandatory to fill in your last name, so the implementation should probably be something like this:
if name.get('family-name', None) is not None:
last_name = name.get('family-name').get('value')
In case the user did not fill in their family name, the line 63:
fullname = first_name = last_name = email = username = ""
already sets last_name
to a default ""
.
I might submit a PR if I find time in the near future. In case somebody is faster I will not be mad :)
This should be resolved on social-core master
, as of commit 95316b0914386af59d8649917c373a594f1766de
(see the above PR for details).
By installing a version of social-core
(package name social-auth-core
) which includes that commit in your environment, social-auth-app-django
should no longer stumble in this case.
Expected behaviour
I should be able to log in with my ORCID account as documented here.
Actual behaviour
After ORCID log in & consent, in the redirection process, I get an
AttributeError
. It happens when getting user details from ORCID response.What are the steps to reproduce this issue?
Input clear steps to reproduce the issue for a maintainer.
<a href="{% url "social:begin" "orcid-sandbox" %}">{% translate 'Sign in with ORCID' %}</a>
to a templateAny logs, error output, etc?
See error log below. Error happens on this line :
last_name = name.get('family-name', {}).get('value', '')
name
is a dict :