def register_temporary_credential_hooks(
        authorization_server, session, model_class):
    """Register temporary credential related hooks to authorization server.

    :param authorization_server: AuthorizationServer instance
    :param session: SQLAlchemy session
    :param model_class: TemporaryCredential class
    """

    def create_temporary_credential(token, client_id, redirect_uri):
        item = model_class(
            client_id=client_id,
            oauth_token=token['oauth_token'],
            oauth_token_secret=token['oauth_token_secret'],
            oauth_callback=redirect_uri,
        )
        session.add(item)
        session.commit()
        return item

    def get_temporary_credential(oauth_token):
        q = session.query(model_class).filter_by(oauth_token=oauth_token)
        return q.first()

    def delete_temporary_credential(oauth_token):
        q = session.query(model_class).filter_by(oauth_token=oauth_token)
        q.delete(synchronize_session=False)
        session.commit()

    def create_authorization_verifier(credential, grant_user, verifier):
        credential.set_user_id(grant_user.get_user_id())
        credential.oauth_verifier = verifier
        session.add(credential)
        session.commit()
        return credential

    authorization_server.register_hook(
        'create_temporary_credential', create_temporary_credential)
    authorization_server.register_hook(
        'get_temporary_credential', get_temporary_credential)
    authorization_server.register_hook(
        'delete_temporary_credential', delete_temporary_credential)
    authorization_server.register_hook(
        'create_authorization_verifier', create_authorization_verifier)