Skip to content

Error while adding access token to the database: AttributeError: 'function' object has no attribute 'create' #1282

Closed Answered by NateXVI
NateXVI asked this question in Q&A
Discussion options

You must be logged in to vote

I figured out the problem. I passed the get_access_token_db function into the DatabaseStrategy class, but I needed to pass the database session returned from the function instead.

-  def get_db_strategy() -> DatabaseStrategy:
-     return DatabaseStrategy(get_access_token_db, lifetime_seconds=3600)
+ def get_db_strategy(session=Depends(get_access_token_db)) -> DatabaseStrategy:
+     return DatabaseStrategy(session, lifetime_seconds=3600)

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by NateXVI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant