# Path: config/setting.py

# 
# Path: model/user.py
# def check(name,info):
# def get_by_id(id):
# def fav_pages(user_id=None,show_private=False,per=5):
# def favs_of_page(page=1,per=5,user_id=0,show_private=False):
# def parse_data(name,info):
# def new_oauth_user(name,info):
# def update_oauth_userid(name,id,oauth_id):
# def update_access_token(name,id,token):
# def exist_oauth_user(name,info):
# def login_oauth_user(name,info):


import requests
import urllib
from config import setting
from model import user
        if not self._token:
            return {}
        req = requests.request(method,url,data=data,headers={"Authorization":self.header_str + " "+self._token})
        json = req.json()
        self.check_err(json)
        return json

    def signed_post(self,url,data={}):
        return self.signed_request("post",url,data=data)

    def signed_get(self,url):
        return self.signed_request("get",url)

    def get_access_token(self,code):
        name = self.name
        data = {
            "client_id":config["auth_"+name+"_key"],
            "client_secret":config["auth_"+name+"_secret"],
            "redirect_uri":config["auth_"+name+"_callback"],
            "grant_type":"authorization_code",
            "code":code
        }
        res_access_token = requests.post(self.access_token_url,data=data)
        res_json = res_access_token.json()
        try:
            self.check_err(res_json)
        except Exception,e:
            return str(e)
        return res_json["access_token"]


# Path: config/setting.py

# 
# Path: model/user.py
# def check(name,info):
# def get_by_id(id):
# def fav_pages(user_id=None,show_private=False,per=5):
# def favs_of_page(page=1,per=5,user_id=0,show_private=False):
# def parse_data(name,info):
# def new_oauth_user(name,info):
# def update_oauth_userid(name,id,oauth_id):
# def update_access_token(name,id,token):
# def exist_oauth_user(name,info):
# def login_oauth_user(name,info):


# Path: util/oauthbase.py
import requests
import urllib
from config import setting
from model import user

        if not self._token:
            return {}
        req = requests.request(method,url,data=data,headers={"Authorization":self.header_str + " "+self._token})
        json = req.json()
        self.check_err(json)
        return json

    def signed_post(self,url,data={}):
        return self.signed_request("post",url,data=data)

    def signed_get(self,url):
        return self.signed_request("get",url)

    def get_access_token(self,code):
        name = self.name
        data = {
            "client_id":config["auth_"+name+"_key"],
            "client_secret":config["auth_"+name+"_secret"],
            "redirect_uri":config["auth_"+name+"_callback"],
            "grant_type":"authorization_code",
            "code":code
        }
        res_access_token = requests.post(self.access_token_url,data=data)
        res_json = res_access_token.json()
        try:
            self.check_err(res_json)
        except Exception,e:
            return str(e)
        return res_json["access_token"]


    def set_user(self,user):