77import json
88import urllib .parse
99import uuid
10- from typing import List , Optional
10+ from typing import Dict , List , Optional , Union
1111
1212import requests
1313import requests_mock .request
@@ -40,6 +40,7 @@ def __init__(
4040 device_code_flow_support : bool = True ,
4141 oidc_discovery_url : Optional [str ] = None ,
4242 support_verification_uri_complete : bool = False ,
43+ access_token_expires_in : Optional [int ] = None ,
4344 ):
4445 self .requests_mock = requests_mock
4546 self .oidc_issuer = oidc_issuer
@@ -54,6 +55,7 @@ def __init__(
5455 self .state = state or {}
5556 self .scopes_supported = scopes_supported or ["openid" , "email" , "profile" ]
5657 self .support_verification_uri_complete = support_verification_uri_complete
58+ self .access_token_expires_in = access_token_expires_in
5759 self .mocks = {}
5860
5961 oidc_discovery_url = oidc_discovery_url or url_join (oidc_issuer , "/.well-known/openid-configuration" )
@@ -255,10 +257,12 @@ def _build_token_response(
255257 _uuid = uuid .uuid4 ().hex ,
256258 ),
257259 )
258- res = {
260+ res : Dict [ str , Union [ str , int , float ]] = {
259261 "token_type" : "Bearer" ,
260262 "access_token" : access_token ,
261263 }
264+ if self .access_token_expires_in is not None :
265+ res ["expires_in" ] = self .access_token_expires_in
262266
263267 # Attempt to simulate real world refresh token support.
264268 if include_refresh_token is None :
0 commit comments