Skip to content

OAuth2 flows with RabbitMQ #1915

Answered by Lancetnik
mdrio asked this question in Q&A
Nov 12, 2024 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

@mdrio

You can try something like that, with lower aio-pika API access

import asyncio
from contextlib import asynccontextmanager
from faststream import FastStream
from faststream.rabbit import RabbitBroker, security

broker = RabbitBroker()

async def update_secret_loop():
    while ...:
        new_token = ...
        broker._connection.update_secret(new_token)

@asynccontextmanager
async def oath_lifespan():
    initial_token = ...
    await broker.connect(security=security.SASLPlaintext("", initial_token))

    task = asyncio.create_task(update_secret_loop())
    yield
    task.cancel()

app = FastStream(broker, lifespan=oath_lifespan)

Unfortunately, we have no public update_secret met…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@mdrio
Comment options

Answer selected by mdrio
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants