-
Hi, I am new to FastStream, I am trying to figure out how to manage OAuth2 flows with faststream and rabbit. Basically, I would like to reimplement this code. I am not sure how to pass the credentials (i.e. the access token) to the broker and refresh when required. |
Beta Was this translation helpful? Give feedback.
Answered by
Lancetnik
Nov 13, 2024
Replies: 1 comment 1 reply
-
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 |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
mdrio
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@mdrio
You can try something like that, with lower aio-pika API access
Unfortunately, we have no public
update_secret
met…