'Return user details from Github account'

def get_user_details(self, response):

    name = (response.get('name') or '')
    details = {'username': response.get('login')}
    try:
        email = self._fetch_emails(response.get('access_token'))[0]
    except IndexError:
        details['email'] = ''
    else:
        details['email'] = email
    try:
        (first_name, last_name) = name.split('    ', 1)
    except ValueError:
        details['first_name'] = name
    else:
        details['first_name'] = first_name
        details['last_name'] = last_name
    return details
