Giter Site home page Giter Site logo

Comments (4)

davidhuser avatar davidhuser commented on June 1, 2024

Hi there,

I cannot yet reproduce after following your steps, with httpx==0.25.1. Can you add some logging as per here?

here's the log output when I tried to reproduce your example.

python main.py


main.py:103: DeprecationWarning:
        on_event is deprecated, use lifespan event handlers instead.

        Read more about it in the
        [FastAPI docs for Lifespan Events](https://fastapi.tiangolo.com/advanced/events/).

  @app.on_event('startup')
  
INFO:     Will watch for changes in these directories: ['/private/tmp']
INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO:     Started reloader process [1762] using StatReload
INFO:     Started server process [1764]
INFO:     Waiting for application startup.
DEBUG 2023-11-16 14:18:03,603 fastapi_azure_auth Loading Azure AD OpenID configuration.
INFO 2023-11-16 14:18:03,619 fastapi_azure_auth Fetching OpenID Connect config from https://mytenant.b2clogin.com/mytenant.onmicrosoft.com/b2c_1_mypolicy/v2.0/.well-known/openid-configuration
INFO 2023-11-16 14:18:04,035 fastapi_azure_auth Fetching jwks from https://mytenant.b2clogin.com/mytenant.onmicrosoft.com/b2c_1_mypolicy/discovery/v2.0/keys
DEBUG 2023-11-16 14:18:04,159 fastapi_azure_auth Loading public key from certificate: {'kid': 'xxx', 'nbf': 1493763266, 'use': 'sig', 'kty': 'RSA', 'e': 'AQAB', 'n': 'xxx'}
INFO 2023-11-16 14:18:04,161 fastapi_azure_auth fastapi-azure-auth loaded settings from Azure AD.
INFO 2023-11-16 14:18:04,161 fastapi_azure_auth authorization endpoint: https://mytenant.b2clogin.com/mytenant.onmicrosoft.com/b2c_1_mypolicy/oauth2/v2.0/authorize
INFO 2023-11-16 14:18:04,161 fastapi_azure_auth token endpoint:         https://mytenant.b2clogin.com/mytenant.onmicrosoft.com/b2c_1_mypolicy/oauth2/v2.0/token
INFO 2023-11-16 14:18:04,162 fastapi_azure_auth issuer:                 https://mytenant.b2clogin.com/xxx/v2.0/
INFO:     Application startup complete.

You could also try to use Lifespan events for loading the config (as the startup events are officially deprecated in FastAPI now).

from fastapi-azure-auth.

kevpye-fabdata avatar kevpye-fabdata commented on June 1, 2024

Hi there, thank you for the very fast response - and for the great work on the library.

Here is the output from the logging config setup you linked to when starting up using httpx 0.25.1. I haven't tried with lifespan events yet. Note the application startup complete message is because the startup code call to load_config is wrapped in a try except

INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO:     Started reloader process [67347] using WatchFiles
INFO:     Started server process [67351]
INFO:     Waiting for application startup.
DEBUG 2023-11-16 15:19:24,014 fastapi_azure_auth Loading Azure AD OpenID configuration.
ERROR 2023-11-16 15:19:24,023 fastapi_azure_auth Unable to fetch OpenID configuration from Azure AD. Error: AsyncConnectionPool.__init__() got an unexpected keyword argument 'socket_options'
Traceback (most recent call last):
  File "/Users/myuserdir/miniconda3/envs/testauthenv/lib/python3.11/site-packages/fastapi_azure_auth/openid_config.py", line 42, in load_config
    await self._load_openid_config()
  File "/Users/myuserdir/miniconda3/envs/testauthenv/lib/python3.11/site-packages/fastapi_azure_auth/openid_config.py", line 77, in _load_openid_config
    async with AsyncClient(timeout=10) as client:
               ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/myuserdir/miniconda3/envs/testauthenv/lib/python3.11/site-packages/httpx/_client.py", line 1397, in __init__
    self._transport = self._init_transport(
                      ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/myuserdir/miniconda3/envs/testauthenv/lib/python3.11/site-packages/httpx/_client.py", line 1445, in _init_transport
    return AsyncHTTPTransport(
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/kevinpye/miniconda3/envs/chatbot_api/lib/python3.11/site-packages/httpx/_transports/default.py", line 275, in __init__
    self._pool = httpcore.AsyncConnectionPool(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: AsyncConnectionPool.__init__() got an unexpected keyword argument 'socket_options'
INFO:     Application startup complete.

from fastapi-azure-auth.

kevpye-fabdata avatar kevpye-fabdata commented on June 1, 2024

Hi again,

I have been doing some further investigation. I updated to lifecycle events but the issue still persisted. After some further debugging It seems like there was an issue on my machine. For some reason, an old version of httpcore - used by httpx was being installed. Once I updated httpcore to the latest version, I could use httpx 0.25.1 and this issue was resolved. I have updated my requirements txt to ensure the correct versions are installed.

You can close this issue, thank you for your help and again thank you for the work on this package and providing clear documentation.

from fastapi-azure-auth.

JonasKs avatar JonasKs commented on June 1, 2024

Glad you resolved it, and thanks @davidhuser for helping out 😊

I’ll close this issue.

As a side note, we should fix startup events in favor as lifespan in the docs, though. Totally forgot about that.

from fastapi-azure-auth.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.