File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -233,4 +233,30 @@ impl Config {
233233 . refresh_access_token_blocking ( expired_at. map ( |t| t. 0 ) )
234234 . map_err ( ErrorNewType ) ?)
235235 }
236+
237+ /// Async version of :meth:`Config.refresh_access_token`. Returns an
238+ /// awaitable; must be awaited inside asyncio.
239+ ///
240+ /// Args:
241+ /// expired_at: The expiration time of the access token (default: 90
242+ /// days from now).
243+ ///
244+ /// Returns:
245+ /// New access token string
246+ #[ pyo3( signature = ( expired_at = None ) ) ]
247+ pub fn refresh_access_token_async (
248+ & self ,
249+ py : Python < ' _ > ,
250+ expired_at : Option < PyOffsetDateTimeWrapper > ,
251+ ) -> PyResult < Py < PyAny > > {
252+ let config = self . 0 . clone ( ) ;
253+ pyo3_async_runtimes:: tokio:: future_into_py ( py, async move {
254+ config
255+ . refresh_access_token ( expired_at. map ( |t| t. 0 ) )
256+ . await
257+ . map_err ( ErrorNewType )
258+ . map_err ( PyErr :: from)
259+ } )
260+ . map ( |b| b. unbind ( ) )
261+ }
236262}
You can’t perform that action at this time.
0 commit comments