1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] Handling MSAL Auth URIs in a Docker container

Discussão em 'Python' iniciado por Stack, Outubro 8, 2024.

  1. Stack

    Stack Membro Participativo

    I'm trying to Dockerize a Python webapp that uses MSAL to handle authentication. I am acquiring the access token by using:

    auth_response = public_app.acquire_token_interactive(scopes=user_scopes, port=5000)

    token = auth_response['access_token']

    The authentication runs smoothly whenever I test it locally. However, when I try to run my code in a Docker container, I get this error message:

    Found no browser in current environment. If this program is being run inside a container which either (1) has access to host network (i.e. started by docker run --net=host -it ...), or (2) published port 5000 to host network (i.e. started by docker run -p 127.0.0.1:5000:5000 -it ...), you can use browser on host to visit the following link. Otherwise, this auth attempt would either timeout (current timeout setting is None) or be aborted by CTRL+C. Auth URI:... `

    When I click on the auth uri generated in the log, I am able to login as normal, and the Docker-ized application runs perfectly. How can I redirect to the generated Auth URI? MSAL uses webbrowser.get() to normally redirect.

    Continue reading...

Compartilhe esta Página