Comments (4)
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.
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.
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.
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)
- [Feature request] support Pydantic v2 syntax / @validator -> @field_validator HOT 5
- [BUG/Question] Fixing TypeError during WebSocket Authentication Migration from FastAPI 0.96 to 0.97 HOT 8
- Calling your APIs from Python not working HOT 22
- [Question] Middleware logging does not get request.state.user HOT 2
- Make leeway a setting available for configuration
- [Question] HOT 6
- [BUG/Question] auth_time is parsed as a string, should be int HOT 2
- [BUG/Question] Got 'Token contains invalid claims' error for the `single tenant setup example ` HOT 6
- [Question] Validate bearer token from Angular SPA (Azure AD) in FastAPI HOT 4
- [Bug/Question] HOT 2
- Adding new fields for Client Secret JWT HOT 1
- [Question] Graph API call triggers "admin consent required" HOT 1
- SOLVED: CVE-2024-23342 `ecdsa` may be vulnerable to the Minerva attack HOT 3
- Facing authentication issue mentioning pkce required for cross-origin authorization code redemption HOT 1
- [BUG] got claim `acct` in type `int`, but fastapi-azure-auth is waiting for `str` HOT 1
- Add ability to specify audience and issuer to validate token claims against HOT 1
- [BUG/Question] Example use cases for scopes HOT 6
- [Feature request] Support WebSocket connections. HOT 1
- Empty raise HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fastapi-azure-auth.