Exemple #1
0
def get_api(request=None):
    api = IndivoClient(settings.CONSUMER_KEY, settings.CONSUMER_SECRET,
                       SMART_SERVER_LOCATION)
    if request:
        api.update_token(request.session['oauth_token_set'])

    return api
Exemple #2
0
def get_indivo_client(request, with_session_token=True):
    client = IndivoClient(settings.INDIVO_SERVER_OAUTH['consumer_key'],
                          settings.INDIVO_SERVER_OAUTH['consumer_secret'],
                          settings.INDIVO_SERVER_LOCATION)
    if with_session_token:
        client.update_token(request.session['access_token'])
    return client
Exemple #3
0
def account_initialization_2(request):
    if request.method == HTTP_METHOD_POST:
        account_id = request.path_info.split('/')[3]
        username = request.POST['username']
        password = request.POST['pw1']
        errors = {
            'generic':
            'There was a problem updating your data. Please try again. If you are unable to set up your account please contact support.'
        }
        api = IndivoClient(settings.CONSUMER_KEY, settings.CONSUMER_SECRET,
                           SMART_SERVER_LOCATION)
        ret = api.add_auth_system(account_id=account_id,
                                  data={
                                      'system': 'password',
                                      'username': username,
                                      'password': password
                                  })

        if ret.response['response_status'] == 200:
            # everything's OK, log this person in, hard redirect to change location
            tokens_get_from_server(request, username, password)
            return HttpResponseRedirect('/')
        else:
            return utils.render_template('ui/account_init_2',
                                         {'ERROR': errors['generic']})
    else:
        return utils.render_template('ui/account_init_2', {})
Exemple #4
0
def account_initialization(request):
    """
  http://localhost/indivoapi/accounts/[email protected]/initialize/icmloNHxQrnCQKNn
  """
    errors = {
        'generic':
        'There was a problem setting up your account. Please try again.'
    }
    api = IndivoClient(settings.CONSUMER_KEY, settings.CONSUMER_SECRET,
                       SMART_SERVER_LOCATION)

    if request.method == HTTP_METHOD_GET:
        return utils.render_template('ui/account_init', {})

    if request.method == HTTP_METHOD_POST:
        # a 404 returned from this call could indicate that the account doesn't exist! Awesome REST logic!
        account_id = request.path_info.split('/')[3]
        ret = api.account_initialize(
            account_id=account_id,
            primary_secret=request.path_info.split('/')[5],
            data={
                'secondary_secret':
                request.POST['conf1'] + request.POST['conf2']
            })

        if ret.response['response_status'] == 200:
            return utils.render_template('ui/account_init_2', {'FULLNAME': ''})
        else:
            return utils.render_template('ui/account_init',
                                         {'ERROR': errors['generic']})
Exemple #5
0
def get_indivo_client(token=None):
    client = IndivoClient(settings.INDIVO_SERVER_OAUTH['consumer_key'],
                          settings.INDIVO_SERVER_OAUTH['consumer_secret'],
                          settings.INDIVO_SERVER_LOCATION)
    if token:
        client.update_token(token)
    return client
Exemple #6
0
 def get_indivo_client(self):
     key, secret = settings.INDIVO_OAUTH_CREDENTIALS
     client = IndivoClient(key, secret, settings.INDIVO_SERVER_LOCATION)
     return client