ask_sdk_model.services.lwa package

Submodules

ask_sdk_model.services.lwa.access_token module

class ask_sdk_model.services.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.services.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.services.lwa.access_token_request module

class ask_sdk_model.services.lwa.access_token_request.AccessTokenRequest(client_id=None, client_secret=None, scope=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
to_dict()

Returns the model properties as a dict

to_str()

Returns the string representation of the model

ask_sdk_model.services.lwa.access_token_response module

class ask_sdk_model.services.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
to_dict()

Returns the model properties as a dict

to_str()

Returns the string representation of the model

ask_sdk_model.services.lwa.error module

class ask_sdk_model.services.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
to_dict()

Returns the model properties as a dict

to_str()

Returns the string representation of the model

ask_sdk_model.services.lwa.lwa_client module

class ask_sdk_model.services.lwa.lwa_client.LwaClient(api_configuration, authentication_configuration)

Bases: ask_sdk_model.services.base_service_client.BaseServiceClient

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

Parameters:
Raises:

ValueError if authentication configuration is not provided.

get_access_token_for_scope(scope)

Retrieve access token for given scope.

Return the scoped access token from the scoped_token_cache if the token is unexpired. If it is expired or is not present, then retrieve a new access token for the given scope, using the client id and client secret in the input ask_sdk_model.services.authentication_configuration.AuthenticationConfiguration instance.

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 and ValueError if LWA AccessTokenResponse is None.