Exemplo n.º 1
0
def get_by_token(access_token):
    with db.engine.connect() as connection:
        result = connection.execute(sqlalchemy.text("""
            SELECT id, client_id, access_token, user_id, refresh_token, expires, scopes
              FROM oauth_token
             WHERE access_token = :access_token
        """), {"access_token": access_token})
        row = result.fetchone()
        if row:
            out = dict(row)
            out["scopes"] = oauth.scopes_string_to_list(out["scopes"])
            return out
        else:
            return None
Exemplo n.º 2
0
def get_by_token(access_token):
    with db.engine.connect() as connection:
        result = connection.execute(
            sqlalchemy.text("""
            SELECT id, client_id, access_token, user_id, refresh_token, expires, scopes
              FROM oauth_token
             WHERE access_token = :access_token
        """), {"access_token": access_token})
        row = result.fetchone()
        if row:
            out = dict(row)
            out["scopes"] = oauth.scopes_string_to_list(out["scopes"])
            return out
        else:
            return None
Exemplo n.º 3
0
def get(client_id, code):
    with db.engine.connect() as connection:
        result = connection.execute(sqlalchemy.text("""
            SELECT id, client_id, user_id, redirect_uri, code, expires, scopes
              FROM oauth_grant
             WHERE client_id = :client_id AND code = :code
        """), {
            "client_id": client_id,
            "code": code,
        })
        row = result.fetchone()
        if row:
            out = dict(row)
            out["scopes"] = oauth.scopes_string_to_list(out["scopes"])
            return out
        else:
            return None