Ejemplo n.º 1
0
def get_user_info_after_auth(request):
  tok = request.session['request_token']
  twitter_client = _get_client_by_token(tok)
  access_token = twitter_client.get_access_token()
  request.session['access_token'] = access_token

  user_info = utils.from_json(twitter_client.oauth_request('http://api.twitter.com/1/account/verify_credentials.json', args={}, method='GET'))

  return {'type': 'twitter', 'user_id' : user_info['screen_name'], 'name': user_info['name'], 'info': user_info, 'token': access_token}
Ejemplo n.º 2
0
def user_needs_intervention(user_id, user_info, token):
  """
  check to see if user is following the users we need
  """
  twitter_client = _get_client_by_token(token)
  friendship = utils.from_json(twitter_client.oauth_request('http://api.twitter.com/1/friendships/exists.json', args={'user_a': user_id, 'user_b': USER_TO_FOLLOW}, method='GET'))
  if friendship:
    return None

  return HttpResponseRedirect(reverse(follow_view))
Ejemplo n.º 3
0
def upload_pk(request, election, trustee):
    with transaction.atomic():
        public_key_and_proof = \
                utils.from_json(request.POST['public_key_json'])
        public_key = algs.EGPublicKey.fromJSONDict(
            public_key_and_proof['public_key'])
        pok = algs.DLogProof.fromJSONDict(public_key_and_proof['pok'])
        election.add_trustee_pk(trustee, public_key, pok)

    return HttpResponseRedirect(
        reverse('election_trustee_home', args=[election.uuid]))
Ejemplo n.º 4
0
def get_user_info_after_auth(request):
  args = facebook_get('/oauth/access_token', {
      'client_id' : APP_ID,
      'redirect_uri' : request.session['fb_redirect_uri'],
      'client_secret' : API_SECRET,
      'code' : request.GET['code']
      })

  access_token = cgi.parse_qs(args)['access_token'][0]

  info = utils.from_json(facebook_get('/me', {'access_token':access_token}))

  return {'type': 'facebook', 'user_id' : info['id'], 'name': info['name'], 'email': info['email'], 'info': info, 'token': {'access_token': access_token}}
Ejemplo n.º 5
0
def user_needs_intervention(user_id, user_info, token):
    """
  check to see if user is following the users we need
  """
    twitter_client = _get_client_by_token(token)
    friendship = utils.from_json(
        twitter_client.oauth_request(
            'http://api.twitter.com/1/friendships/exists.json',
            args={
                'user_a': user_id,
                'user_b': USER_TO_FOLLOW
            },
            method='GET'))
    if friendship:
        return None

    return HttpResponseRedirect(reverse(follow_view))
Ejemplo n.º 6
0
def get_user_info_after_auth(request):
    tok = request.session['request_token']
    twitter_client = _get_client_by_token(tok)
    access_token = twitter_client.get_access_token()
    request.session['access_token'] = access_token

    user_info = utils.from_json(
        twitter_client.oauth_request(
            'http://api.twitter.com/1/account/verify_credentials.json',
            args={},
            method='GET'))

    return {
        'type': 'twitter',
        'user_id': user_info['screen_name'],
        'name': user_info['name'],
        'info': user_info,
        'token': access_token
    }
Ejemplo n.º 7
0
def get_user_info_after_auth(request):
    args = facebook_get(
        '/oauth/access_token', {
            'client_id': APP_ID,
            'redirect_uri': request.session['fb_redirect_uri'],
            'client_secret': API_SECRET,
            'code': request.GET['code']
        })

    access_token = cgi.parse_qs(args)['access_token'][0]

    info = utils.from_json(facebook_get('/me', {'access_token': access_token}))

    return {
        'type': 'facebook',
        'user_id': info['id'],
        'name': info['name'],
        'email': info['email'],
        'info': info,
        'token': {
            'access_token': access_token
        }
    }
Ejemplo n.º 8
0
def get_user_groups(user):
  groups_raw = utils.from_json(facebook_get('/me/groups', {'access_token':user.token['access_token']}))
  return groups_raw['data']
Ejemplo n.º 9
0
def get_user_groups(user):
    groups_raw = utils.from_json(
        facebook_get('/me/groups',
                     {'access_token': user.token['access_token']}))
    return groups_raw['data']