example/qq.py
def json_to_dict(x):
    '''OAuthResponse class can't parse the JSON data with content-type
-    text/html and because of a rubbish api, we can't just tell flask-oauthlib to treat it as json.'''
    if x.find(b'callback') > -1:
        # the rubbish api (https://graph.qq.com/oauth2.0/authorize) is handled here as special case
        pos_lb = x.find(b'{')
        pos_rb = x.find(b'}')
        x = x[pos_lb:pos_rb + 1]

    try:
        if type(x) != str:  # Py3k
            x = x.decode('utf-8')
        return json.loads(x, encoding='utf-8')
    except:
        return x
def json_to_dict(x):
    '''OAuthResponse class can't parse the JSON data with content-type
-    text/html and because of a rubbish api, we can't just tell flask-oauthlib to treat it as json.'''
    if x.find(b'callback') > -1:
        # the rubbish api (https://graph.qq.com/oauth2.0/authorize) is handled here as special case
        pos_lb = x.find(b'{')
        pos_rb = x.find(b'}')
        x = x[pos_lb:pos_rb + 1]

    try:
        if type(x) != str:  # Py3k
            x = x.decode('utf-8')
        return json.loads(x, encoding='utf-8')
    except:
        return x
def json_to_dict ( x ) : if x . find ( b'callback' ) > - 1 : # the rubbish api (https://graph.qq.com/oauth2.0/authorize) is handled here as special case pos_lb = x . find ( b'{' ) pos_rb = x . find ( b'}' ) x = x [ pos_lb : pos_rb + 1 ] try : if type ( x ) != str : # Py3k x = x . decode ( 'utf-8' ) return json . loads ( x , encoding = 'utf-8' ) except : return x
OAuthResponse class can't parse the JSON data with content-type
-    text/html and because of a rubbish api, we can't just tell flask-oauthlib to treat it as json.
OAuthResponse class can t parse the JSON data with content - type - text / html and because of a rubbish api we can t just tell flask - oauthlib to treat it as json .