Beispiel #1
0
    def create_request_token(self, request, oauth_request, consumer, callback,
                             session=None):
        consumer = session.query(Consumer) \
                          .filter_by(key=oauth_request['oauth_consumer_key']) \
                          .first()
        oauth_ts = float(oauth_request['oauth_timestamp'])
        timestamp = datetime.fromtimestamp(oauth_ts)
        token = Token.create(token_type=Token.REQUEST, consumer=consumer,
                             timestamp=timestamp, _commit=False,
                             session=session)
        token.set_callback(callback, session=session)

        return token
Beispiel #2
0
    def create_access_token(self, request, oauth_request, consumer,
                            request_token, session=None):
        sconsumer = session.query(Consumer) \
                           .filter_by(key=consumer.key) \
                           .first()
        oauth_ts = float(oauth_request['oauth_timestamp'])
        timestamp = datetime.fromtimestamp(oauth_ts)
        access_token = Token.create(token_type=Token.ACCESS,
                                    timestamp=timestamp, consumer=sconsumer,
                                    user=request_token.user, session=session,
                                    _commit=False)
        session.delete(request_token)
        session.commit()

        return access_token
Beispiel #3
0
    def create_request_token(self,
                             request,
                             oauth_request,
                             consumer,
                             callback,
                             session=None):
        consumer = session.query(Consumer) \
                          .filter_by(key=oauth_request['oauth_consumer_key']) \
                          .first()
        oauth_ts = float(oauth_request['oauth_timestamp'])
        timestamp = datetime.fromtimestamp(oauth_ts)
        token = Token.create(token_type=Token.REQUEST,
                             consumer=consumer,
                             timestamp=timestamp,
                             _commit=False,
                             session=session)
        token.set_callback(callback, session=session)

        return token
Beispiel #4
0
    def create_access_token(self,
                            request,
                            oauth_request,
                            consumer,
                            request_token,
                            session=None):
        sconsumer = session.query(Consumer) \
                           .filter_by(key=consumer.key) \
                           .first()
        oauth_ts = float(oauth_request['oauth_timestamp'])
        timestamp = datetime.fromtimestamp(oauth_ts)
        access_token = Token.create(token_type=Token.ACCESS,
                                    timestamp=timestamp,
                                    consumer=sconsumer,
                                    user=request_token.user,
                                    session=session,
                                    _commit=False)
        session.delete(request_token)
        session.commit()

        return access_token