File tree Expand file tree Collapse file tree
google/cloud/alloydbconnector Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -216,12 +216,12 @@ async def connect(
216216 logger .debug (f"['{ instance_uri } ']: Connecting to { ip_address } :5433" )
217217
218218 # callable to be used for auto IAM authn
219- def get_authentication_token () -> str :
219+ async def get_authentication_token () -> str :
220220 """Get OAuth2 access token to be used for IAM database authentication"""
221221 # refresh credentials if expired
222222 if not self ._db_credentials .valid :
223223 request = google .auth .transport .requests .Request ()
224- self ._db_credentials .refresh ( request )
224+ await asyncio . to_thread ( self ._db_credentials .refresh , request )
225225 return self ._db_credentials .token
226226
227227 # if enable_iam_auth is set, use auth token as database password
Original file line number Diff line number Diff line change @@ -240,7 +240,7 @@ async def test_connect_iam_authn(credentials: FakeCredentials) -> None:
240240
241241 async def custom_connect (* _ : Any , ** kwargs : Any ) -> bool :
242242 passwd = kwargs .pop ("password" )
243- passwd ()
243+ await passwd ()
244244
245245 # patch db connection creation
246246 with patch (
@@ -272,7 +272,7 @@ async def test_connect_db_credentials_iam_authn(credentials: FakeCredentials) ->
272272
273273 async def custom_connect (* _ : Any , ** kwargs : Any ) -> bool :
274274 passwd = kwargs .pop ("password" )
275- passwd ()
275+ await passwd ()
276276
277277 # patch db connection creation
278278 with patch (
You can’t perform that action at this time.
0 commit comments