You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've got 7 emails in my GitHub account.. but I selected one as my primary. python-social-auth just takes the first one in the provided list, disregarding my selection. I have stale e-mails in there.. Think we could pick the primary e-mail!
This was an attempt to monkey patch django-social-auth with the intended behavior. If there's interest, I can make it a PR in python-social-auth:
# re-implements: backends/contrib/github.py:L57-66
def _fetch_emails_replacement(self, access_token):
"""Fetch private emails from Github account
Github returns something like:
[
{
"email": "octocat@github.com",
"verified": true,
"primary": true
}
]
"""
url = GITHUB_USER_DATA_URL + '/emails?' + urlencode({
'access_token': access_token
})
try:
data = simplejson.load(dsa_urlopen(url))
except (ValueError, HTTPError):
return []
emails = [x['email'] for x in data
if x['primary']]
if emails:
return [emails[0]]
else:
if data:
return [data[0]['email']]
else:
return []
github.GithubBackend._fetch_emails = _fetch_emails_replacement
The text was updated successfully, but these errors were encountered:
I've got 7 emails in my GitHub account.. but I selected one as my primary.
python-social-auth
just takes the first one in the provided list, disregarding my selection. I have stale e-mails in there.. Think we could pick the primary e-mail!This was an attempt to monkey patch
django-social-auth
with the intended behavior. If there's interest, I can make it a PR inpython-social-auth
:The text was updated successfully, but these errors were encountered: