def getUser(self, token):
        headers = {
            'Authorization': 'token %s' % token['access_token'],
            'Accept': 'application/json'
        }

        # Get user's email address
        # In the unlikely case that a user has more than 30 email addresses,
        # this HTTP request might have to be made multiple times with pagination
        resp = self._getJson(method='GET', url=self._API_EMAILS_URL,
                             headers=headers)
        emails = [
            email.get('email')
            for email in resp
            if email.get('primary') and email.get('verified')
        ]
        if not emails:
            raise RestException(
                'This GitHub user has no registered email address.', code=502)
        # There should never be more than one primary email
        email = emails[0]

        # Get user's OAuth2 ID, login, and name
        resp = self._getJson(method='GET', url=self._API_USER_URL,
                             headers=headers)
        oauthId = resp.get('id')
        if not oauthId:
            raise RestException('GitHub did not return a user ID.', code=502)

        login = resp.get('login', None)

        names = resp.get('name', '').split()
        firstName = names[0] if names else ''
        lastName = names[-1] if len(names) > 1 else ''

        user = self._createOrReuseUser(oauthId, email, firstName, lastName,
                                       login)
        return user
dataset/ETHPy150Open girder/girder/plugins/oauth/server/providers/github.py/GitHub.getUser/original