'Return user data provided'

def user_data(self, access_token):

    url = BITBUCKET_EMAIL_DATA_URL
    request = self.oauth_request(access_token, url)
    response = self.fetch_response(request)
    try:
        email_addresses = simplejson.loads(response)
        for email_address in reversed(email_addresses):
            if email_address['active']:
                email = email_address['email']
                if email_address['primary']:
                    break
        response = dsa_urlopen((BITBUCKET_USER_DATA_URL + email))
        user_details = simplejson.load(response)['user']
        user_details['email'] = email
        return user_details
    except ValueError:
        return None
    return None
