@@ -1428,12 +1428,16 @@ def login_as_app(
14281428 self .session .app_bearer_token_auth (token , expire_in )
14291429
14301430 def login_as_app_installation (
1431- self , private_key_pem , app_id , installation_id
1431+ self , private_key_pem , app_id , installation_id , expire_in = 30
14321432 ):
14331433 """Login using your GitHub App's installation credentials.
14341434
14351435 .. versionadded:: 1.2.0
14361436
1437+ .. versionchanged:: 3.0.0
1438+
1439+ Added ``expire_in`` parameter.
1440+
14371441 .. seealso::
14381442
14391443 `Authenticating as an Installation`_
@@ -1455,17 +1459,23 @@ def login_as_app_installation(
14551459 The integer identifier for this GitHub Application.
14561460 :param int installation_id:
14571461 The integer identifier of your App's installation.
1462+ :param int expire_in:
1463+ (Optional) The number of seconds in the future that the underlying
1464+ JWT expires. To prevent tokens from being valid for too long and
1465+ creating a security risk, the library defaults to 30 seconds. In
1466+ the event that clock drift is significant between your machine and
1467+ GitHub's servers, you can set this higher than 30.
1468+ Default: 30
14581469
14591470 .. _Authenticating as an Installation:
14601471 https://developer.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-an-installation
14611472 .. _Create a new installation token:
14621473 https://developer.github.com/v3/apps/#create-a-new-installation-token
14631474 """
1464- # NOTE(sigmavirus24): This JWT token does not need to last very long.
1465- # Instead of allowing it to stick around for 10 minutes, let's limit
1466- # it to 30 seconds.
1467- jwt_token = apps .create_token (private_key_pem , app_id , expire_in = 30 )
1468- bearer_auth = session .AppBearerTokenAuth (jwt_token , 30 )
1475+ jwt_token = apps .create_token (
1476+ private_key_pem , app_id , expire_in = expire_in
1477+ )
1478+ bearer_auth = session .AppBearerTokenAuth (jwt_token , expire_in )
14691479 url = self ._build_url (
14701480 "app" , "installations" , str (installation_id ), "access_tokens"
14711481 )
0 commit comments