ask_sdk_model_runtime.lwa package

Submodules

Note

Canonical imports have been added in the __init__.py of the package. This helps in importing the class directly from the package, than through the module.

For eg: if package a has module b with class C, you can do from a import C instead of from a.b import C.

ask_sdk_model_runtime.lwa.access_token module

class ask_sdk_model_runtime.lwa.access_token.AccessToken(token=None, expiry=None)

Bases: object

Represents the access token provided by LWA (Login With Amazon).

This is a wrapper class over ask_sdk_model_runtime.lwa.access_token_response.AccessTokenResponse that retrieves and stores the access token, the expiry time from LWA response.

Parameters:
  • token (str) – access token from LWA
  • expiry (datetime) – exact timestamp in UTC datetime, which is the expiry time for this access token. This is set as the combined datetime of current system time when the LWA response is received and the expiry time in seconds, provided in the LWA response.

ask_sdk_model_runtime.lwa.access_token_request module

class ask_sdk_model_runtime.lwa.access_token_request.AccessTokenRequest(client_id=None, client_secret=None, scope=None, refresh_token=None)

Bases: object

Request for retrieving an access token from LWA.

Parameters:
  • client_id (str) – The ClientId value from developer console
  • client_secret (str) – The ClientSecret value from developer console
  • scope (str) – The required scope for which the access token is requested for
  • refresh_token (str) – Client refresh_token required to get access token for API calls.
attribute_map = {'client_id': 'client_id', 'client_secret': 'client_secret', 'refresh_token': 'refresh_token', 'scope': 'scope'}
deserialized_types = {'client_id': 'str', 'client_secret': 'str', 'refresh_token': 'str', 'scope': 'str'}
to_dict()

Returns the model properties as a dict

to_str()

Returns the string representation of the model

ask_sdk_model_runtime.lwa.access_token_response module

class ask_sdk_model_runtime.lwa.access_token_response.AccessTokenResponse(access_token=None, expires_in=None, scope=None, token_type=None)

Bases: object

LWA response for retrieving an access token.

Parameters:
  • access_token (str) – The access token from LWA
  • expires_in (int) – The duration in seconds of the access token lifetime
  • scope (str) – The scope specified in the access token request
  • token_type (str) – The type of token issued
attribute_map = {'access_token': 'access_token', 'expires_in': 'expires_in', 'scope': 'scope', 'token_type': 'token_type'}
deserialized_types = {'access_token': 'str', 'expires_in': 'int', 'scope': 'str', 'token_type': 'str'}
to_dict()

Returns the model properties as a dict

to_str()

Returns the string representation of the model

ask_sdk_model_runtime.lwa.error module

class ask_sdk_model_runtime.lwa.error.Error(error_description=None, error_type=None)

Bases: object

Error from LWA Client request.

Parameters:
  • error_description ((optional) str) – Description of the error
  • error_type ((optional) str) – Type of error
attribute_map = {'error_description': 'error_description', 'error_type': 'error'}
deserialized_types = {'error_description': 'str', 'error_type': 'str'}
to_dict()

Returns the model properties as a dict

to_str()

Returns the string representation of the model

ask_sdk_model_runtime.lwa.lwa_client module

class ask_sdk_model_runtime.lwa.lwa_client.LwaClient(api_configuration, authentication_configuration, grant_type=None)

Bases: ask_sdk_model_runtime.base_service_client.BaseServiceClient

Client to call Login with Amazon (LWA) to retrieve access tokens.

Parameters:
Raises:

ValueError if authentication configuration is not provided.

CLIENT_CREDENTIALS_GRANT_TYPE = 'client_credentials'
DEFAULT_LWA_ENDPOINT = 'https://api.amazon.com'
EXPIRY_OFFSET_IN_MILLIS = 60000
LWA_CREDENTIALS_GRANT_TYPE = 'refresh_token'
REFRESH_ACCESS_TOKEN = 'refresh_access_token'
get_access_token_for_scope(scope)

Retrieve access token for given scope.

Parameters:scope (str) – Target scope for the access token
Returns:Retrieved access token for the given scope and configured client id, client secret
Return type:str
Raises:ValueError is no scope is passed.
get_access_token_from_refresh_token()

Retrieve access token for Skill Management API calls.

Returns:Retrieved access token for the given refresh_token and configured client id, client secret
Return type:str