This API works with the following fleet types: EC2, Anywhere, Container
Requests an authentication token from Amazon GameLift Servers for a compute resource in an Amazon GameLift Servers fleet. Game servers that are running on the compute use this token to communicate with the Amazon GameLift Servers service, such as when calling the Amazon GameLift Servers server SDK action InitSDK(). Authentication tokens are valid for a limited time span, so you need to request a fresh token before the current token expires.
Request options
-
For managed EC2 fleets (compute type EC2), auth token retrieval and refresh is handled automatically. All game servers that are running on all fleet instances have access to a valid auth token.
-
For Anywhere fleets (compute type ANYWHERE), if you're using the Amazon GameLift Servers Agent, auth token retrieval and refresh is handled automatically for any compute where the Agent is running. If you're not using the Agent, create a mechanism to retrieve and refresh auth tokens for computes that are running game server processes.
Learn more
Parameters:
-
fleet_id
(Optional[FleetIdOrArn], default:
None
)
–
A unique identifier for the fleet that the compute is registered to.
-
compute_name
(Optional[ComputeNameOrArn], default:
None
)
–
The name of the compute resource you are requesting the authentication token for. For an Anywhere fleet compute, use the registered compute name. For an EC2 fleet instance, use the instance ID.
Raises:
-
InternalServiceException
–
The service encountered an unrecoverable internal failure while processing the request. Clients can retry such requests immediately or after a waiting period.
-
InvalidRequestException
–
One or more parameter values in the request are invalid. Correct the invalid parameter values before retrying.
-
NotFoundException
–
The requested resource was not found. The resource was either not created yet or deleted.
-
UnauthorizedException
–
The client failed authentication. Clients should not retry such requests.
-
UnsupportedRegionException
–
The requested operation is not supported in the Region specified.
-
UnknownServiceError
–
The service returned an error code this client does not model.
Source code in docs_src/capo_gamelift/_services/async_game_lift.py
| async def get_compute_auth_token(
self,
*,
config_overrides: Optional[AsyncGameLiftClientConfig] = None,
fleet_id: Optional["capo_gamelift.types.fleet_id_or_arn.FleetIdOrArn"] = None,
compute_name: Optional[
"capo_gamelift.types.compute_name_or_arn.ComputeNameOrArn"
] = None,
) -> "capo_gamelift.types.get_compute_auth_token_output.GetComputeAuthTokenOutput":
"""<p> <b>This API works with the following fleet types:</b> EC2, Anywhere, Container</p> <p>Requests an authentication token from Amazon GameLift Servers for a compute resource in an Amazon GameLift Servers fleet. Game servers that are running on the compute use this token to communicate with the Amazon GameLift Servers service, such as when calling the Amazon GameLift Servers server SDK action <code>InitSDK()</code>. Authentication tokens are valid for a limited time span, so you need to request a fresh token before the current token expires.</p> <p> <b>Request options</b> </p> <ul> <li> <p>For managed EC2 fleets (compute type <code>EC2</code>), auth token retrieval and refresh is handled automatically. All game servers that are running on all fleet instances have access to a valid auth token.</p> </li> <li> <p>For Anywhere fleets (compute type <code>ANYWHERE</code>), if you're using the Amazon GameLift Servers Agent, auth token retrieval and refresh is handled automatically for any compute where the Agent is running. If you're not using the Agent, create a mechanism to retrieve and refresh auth tokens for computes that are running game server processes.</p> </li> </ul> <p> <b>Learn more</b> </p> <ul> <li> <p> <a href="https://docs.aws.amazon.com/gamelift/latest/developerguide/fleets-creating-anywhere.html">Create an Anywhere fleet</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/gamelift/latest/developerguide/integration-testing.html">Test your integration</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/gamelift/latest/developerguide/reference-serversdk.html">Server SDK reference guides</a> (for version 5.x)</p> </li> </ul>
Args:
fleet_id: <p>A unique identifier for the fleet that the compute is registered to.</p>
compute_name: <p>The name of the compute resource you are requesting the authentication token for. For an Anywhere fleet compute, use the registered compute name. For an EC2 fleet instance, use the instance ID.</p>
Raises:
capo_gamelift.errors.internal_service_exception.InternalServiceException: <p>The service encountered an unrecoverable internal failure while processing the request. Clients can retry such requests immediately or after a waiting period.</p>
capo_gamelift.errors.invalid_request_exception.InvalidRequestException: <p>One or more parameter values in the request are invalid. Correct the invalid parameter values before retrying.</p>
capo_gamelift.errors.not_found_exception.NotFoundException: <p>The requested resource was not found. The resource was either not created yet or deleted.</p>
capo_gamelift.errors.unauthorized_exception.UnauthorizedException: <p>The client failed authentication. Clients should not retry such requests.</p>
capo_gamelift.errors.unsupported_region_exception.UnsupportedRegionException: <p>The requested operation is not supported in the Region specified.</p>
capo_gamelift.errors.UnknownServiceError: The service returned an error code this client does not model.
"""
async def _handler(
req: "AsyncOperationRequest[capo_gamelift.types.get_compute_auth_token_input.GetComputeAuthTokenInput]",
) -> AsyncOperationResponse[
"capo_gamelift.types.get_compute_auth_token_output.GetComputeAuthTokenOutput"
]:
import capo_gamelift._operations.game_lift.get_compute_auth_token
(
output,
http_response,
) = await capo_gamelift._operations.game_lift.get_compute_auth_token.async_get_compute_auth_token(
req.options, req.input
)
return AsyncOperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("GetComputeAuthToken")
)
input_: capo_gamelift.types.get_compute_auth_token_input.GetComputeAuthTokenInput = {}
if fleet_id is not None:
input_["fleet_id"] = fleet_id
if compute_name is not None:
input_["compute_name"] = compute_name
response = await aexecute_pipeline(
AsyncOperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
await response.response.aclose()
return response.output
|