def new_access(): bottle_app.oauth = setup_oauth(r_c, conf_obj, store_tokens_callback) secret_keys = r_c.get('secret_keys') if not secret_keys: secret_keys = [] else: secret_keys = json.loads(str(secret_keys, encoding='utf-8', errors='strict')) if str(bottle.request.POST.get('diycrate_secret_key')) not in secret_keys: raise ValueError('No matching secret key; we are being secure!') return json.dumps([el.decode(encoding='utf-8', errors='strict') if isinstance(el, bytes) else el for el in bottle_app.oauth.refresh(bottle.request.POST.get('access_token'))])
def auth_url(): bottle_app.oauth = setup_oauth(r_c, conf_obj, store_tokens_callback) secret_keys = r_c.get('secret_keys') if not secret_keys: secret_keys = [] else: secret_keys = json.loads(secret_keys.decode(encoding='utf-8', errors='strict')) if bottle.request.POST.get('diycrate_secret_key') not in secret_keys: secret_keys.append(str(bottle.request.POST.get('diycrate_secret_key'))) r_c.set('secret_keys', json.dumps(secret_keys)) return json.dumps([el.decode(encoding='utf-8', errors='strict') if isinstance(el, bytes) else el for el in bottle_app.oauth.authenticate(auth_code=bottle.request.POST.get('code'))])