AlexaClientSDK  1.26.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Classes | Functions | Variables
alexaClientSDK::authorization::cblAuthDelegate Namespace Reference

Classes

class  CBLAuthDelegate
 
class  CBLAuthDelegateStorageInterface
 
class  CBLAuthRequesterInterface
 
class  SQLiteCBLAuthDelegateStorage
 

Functions

static const std::string TAG ("CBLAuthDelegate")
 String to identify log entries originating from this file. More...
 
static AuthObserverInterface::Error getErrorCode (const std::string &error)
 
static std::chrono::steady_clock::time_point calculateTimeToRetry (int retryCount)
 
static AuthObserverInterface::Error mapHTTPCodeToError (long code)
 
AuthObserverInterface::Error parseLWAResponse (const avsCommon::utils::libcurlUtils::HTTPResponse &response, rapidjson::Document *document)
 
static const std::string TAG ("SQLiteCBLAuthDelegateStorage")
 String to identify log entries originating from this file. More...
 

Variables

static const char JSON_KEY_USER_CODE [] = "user_code"
 Key for user_code values in JSON returned by LWA. More...
 
static const char JSON_KEY_DEVICE_CODE [] = "device_code"
 Key for device_code values in JSON returned by LWA. More...
 
static const char JSON_KEY_VERIFICATION_URI [] = "verification_uri"
 Key for verification_uri values in JSON returned by LWA. More...
 
static const char JSON_KEY_EXPIRES_IN [] = "expires_in"
 Key for expires_in values in JSON returned by LWA. More...
 
static const char JSON_KEY_INTERVAL [] = "interval"
 Key for interval values in JSON returned by LWA. More...
 
static const char JSON_KEY_TOKEN_TYPE [] = "token_type"
 Key for interval values in JSON returned by LWA. More...
 
static const char JSON_KEY_ACCESS_TOKEN [] = "access_token"
 Key for access_token values in JSON returned by LWA. More...
 
static const char JSON_KEY_REFRESH_TOKEN [] = "refresh_token"
 Key for refresh_token values in JSON returned by LWA. More...
 
static const char JSON_KEY_ERROR [] = "error"
 Key for error values in JSON returned by LWA. More...
 
static const std::string CONFIG_ROOT_KEY = "cblAuthDelegate"
 Key for the the root config. More...
 
static const std::string JSON_VALUE_BEARER = "bearer"
 Expected token_type value returned from token requests to LWA. More...
 
static const std::string POST_KEY_RESPONSE_TYPE = "response_type"
 response_type key in POST requests to LWA. More...
 
static const std::string POST_KEY_CLIENT_ID = "client_id"
 client_id key in POST requests to LWA. More...
 
static const std::string POST_KEY_SCOPE = "scope"
 scope key in POST requests to LWA. More...
 
static const std::string POST_KEY_SCOPE_DATA = "scope_data"
 scope_data key in POST requests to LWA. More...
 
static const std::string POST_KEY_GRANT_TYPE = "grant_type"
 grant_type key in POST requests to LWA. More...
 
static const std::string POST_KEY_DEVICE_CODE = "device_code"
 device_code key in POST requests to LWA. More...
 
static const std::string POST_KEY_USER_CODE = "user_code"
 user_code key in POST requests to LWA. More...
 
static const std::string POST_KEY_REFRESH_TOKEN = "refresh_token"
 refresh_token key in POST requests to LWA. More...
 
static const std::string POST_VALUE_REFRESH_TOKEN = "refresh_token"
 refresh_token value in POST requests to LWA. More...
 
static const std::string POST_VALUE_DEVICE_CODE = "device_code"
 device_code value in POST requests to LWA. More...
 
static const std::string POST_VALUE_ALEXA_ALL = "alexa:all"
 alexa:all value in POST requests to LWA. More...
 
static const std::string HEADER_LINE_URLENCODED = "Content-Type: application/x-www-form-urlencoded"
 HTTP Header line specifying URL encoded data. More...
 
static const std::string HEADER_LINE_LANGUAGE_PREFIX = "Accept-Language: "
 Prefix of HTTP header line specifying language. More...
 
static const std::chrono::seconds MIN_TOKEN_REQUEST_INTERVAL = std::chrono::seconds(5)
 Min time to wait between attempt to poll for a token while authentication is pending. More...
 
static const std::chrono::seconds MAX_TOKEN_REQUEST_INTERVAL = std::chrono::seconds(60)
 Max time to wait between attempt to poll for a token while authentication is pending. More...
 
static const int TOKEN_REQUEST_SLOW_DOWN_FACTOR = 2
 Scale factor to apply to interval between token poll requests when a 'slow_down' response is received. More...
 
static const std::unordered_map< std::string, AuthObserverInterface::Errorg_nameToErrorMap
 Map error names from LWA to AuthObserverInterface::Error values. More...
 
static const std::string CONFIG_KEY_CBL_AUTH_DELEGATE = "cblAuthDelegate"
 Name of ConfigurationNode for CBLAuthDelegate. More...
 

Function Documentation

◆ calculateTimeToRetry()

static std::chrono::steady_clock::time_point alexaClientSDK::authorization::cblAuthDelegate::calculateTimeToRetry ( int  retryCount)
static

Function to convert the number of times we have already retried to the time to perform the next retry.

Parameters
retryCountThe number of times we have retried
Returns
The time that the next retry should be attempted

Table of retry backoff values

◆ getErrorCode()

static AuthObserverInterface::Error alexaClientSDK::authorization::cblAuthDelegate::getErrorCode ( const std::string &  error)
static

Helper function to convert from LWA error names to AuthObserverInterface::Error values.

Parameters
errorThe string in the error field returned by LWA
Returns
the Error enum code corresponding to error. If error is "", returns SUCCESS. If it is an unknown error, returns UNKNOWN_ERROR.

◆ mapHTTPCodeToError()

static AuthObserverInterface::Error alexaClientSDK::authorization::cblAuthDelegate::mapHTTPCodeToError ( long  code)
static

Map an HTTP status code to an AuthObserverInterface::Error value.

Parameters
codeThe code to map from.
Returns
The value the code was mapped to.

◆ parseLWAResponse()

AuthObserverInterface::Error alexaClientSDK::authorization::cblAuthDelegate::parseLWAResponse ( const avsCommon::utils::libcurlUtils::HTTPResponse response,
rapidjson::Document *  document 
)

Perform common parsing of an LWA response.

Parameters
responseThe response to parse.
documentThe document to populate from the body of the response.
Returns
The status from the initial parsing of the response.

◆ TAG() [1/2]

static const std::string alexaClientSDK::authorization::cblAuthDelegate::TAG ( "CBLAuthDelegate"  )
static

String to identify log entries originating from this file.

◆ TAG() [2/2]

static const std::string alexaClientSDK::authorization::cblAuthDelegate::TAG ( "SQLiteCBLAuthDelegateStorage"  )
static

String to identify log entries originating from this file.

Variable Documentation

◆ CONFIG_KEY_CBL_AUTH_DELEGATE

const std::string alexaClientSDK::authorization::cblAuthDelegate::CONFIG_KEY_CBL_AUTH_DELEGATE = "cblAuthDelegate"
static

Name of ConfigurationNode for CBLAuthDelegate.

◆ CONFIG_ROOT_KEY

const std::string alexaClientSDK::authorization::cblAuthDelegate::CONFIG_ROOT_KEY = "cblAuthDelegate"
static

Key for the the root config.

◆ g_nameToErrorMap

const std::unordered_map<std::string, AuthObserverInterface::Error> alexaClientSDK::authorization::cblAuthDelegate::g_nameToErrorMap
static
Initial value:
= {
{"authorization_pending", AuthObserverInterface::Error::AUTHORIZATION_PENDING},
{"invalid_client", AuthObserverInterface::Error::INVALID_VALUE},
{"invalid_code_pair", AuthObserverInterface::Error::INVALID_CODE_PAIR},
{"invalid_grant", AuthObserverInterface::Error::AUTHORIZATION_EXPIRED},
{"invalid_request", AuthObserverInterface::Error::INVALID_REQUEST},
{"InvalidValue", AuthObserverInterface::Error::INVALID_VALUE},
{"servererror", AuthObserverInterface::Error::SERVER_ERROR},
{"slow_down", AuthObserverInterface::Error::SLOW_DOWN},
{"unauthorized_client", AuthObserverInterface::Error::UNAUTHORIZED_CLIENT},
{"unsupported_grant_type", AuthObserverInterface::Error::UNSUPPORTED_GRANT_TYPE}}

Map error names from LWA to AuthObserverInterface::Error values.

◆ HEADER_LINE_LANGUAGE_PREFIX

const std::string alexaClientSDK::authorization::cblAuthDelegate::HEADER_LINE_LANGUAGE_PREFIX = "Accept-Language: "
static

Prefix of HTTP header line specifying language.

◆ HEADER_LINE_URLENCODED

const std::string alexaClientSDK::authorization::cblAuthDelegate::HEADER_LINE_URLENCODED = "Content-Type: application/x-www-form-urlencoded"
static

HTTP Header line specifying URL encoded data.

◆ JSON_KEY_ACCESS_TOKEN

const char alexaClientSDK::authorization::cblAuthDelegate::JSON_KEY_ACCESS_TOKEN[] = "access_token"
static

Key for access_token values in JSON returned by LWA.

◆ JSON_KEY_DEVICE_CODE

const char alexaClientSDK::authorization::cblAuthDelegate::JSON_KEY_DEVICE_CODE[] = "device_code"
static

Key for device_code values in JSON returned by LWA.

◆ JSON_KEY_ERROR

const char alexaClientSDK::authorization::cblAuthDelegate::JSON_KEY_ERROR[] = "error"
static

Key for error values in JSON returned by LWA.

◆ JSON_KEY_EXPIRES_IN

const char alexaClientSDK::authorization::cblAuthDelegate::JSON_KEY_EXPIRES_IN[] = "expires_in"
static

Key for expires_in values in JSON returned by LWA.

◆ JSON_KEY_INTERVAL

const char alexaClientSDK::authorization::cblAuthDelegate::JSON_KEY_INTERVAL[] = "interval"
static

Key for interval values in JSON returned by LWA.

◆ JSON_KEY_REFRESH_TOKEN

const char alexaClientSDK::authorization::cblAuthDelegate::JSON_KEY_REFRESH_TOKEN[] = "refresh_token"
static

Key for refresh_token values in JSON returned by LWA.

◆ JSON_KEY_TOKEN_TYPE

const char alexaClientSDK::authorization::cblAuthDelegate::JSON_KEY_TOKEN_TYPE[] = "token_type"
static

Key for interval values in JSON returned by LWA.

◆ JSON_KEY_USER_CODE

const char alexaClientSDK::authorization::cblAuthDelegate::JSON_KEY_USER_CODE[] = "user_code"
static

Key for user_code values in JSON returned by LWA.

◆ JSON_KEY_VERIFICATION_URI

const char alexaClientSDK::authorization::cblAuthDelegate::JSON_KEY_VERIFICATION_URI[] = "verification_uri"
static

Key for verification_uri values in JSON returned by LWA.

◆ JSON_VALUE_BEARER

const std::string alexaClientSDK::authorization::cblAuthDelegate::JSON_VALUE_BEARER = "bearer"
static

Expected token_type value returned from token requests to LWA.

◆ MAX_TOKEN_REQUEST_INTERVAL

const std::chrono::seconds alexaClientSDK::authorization::cblAuthDelegate::MAX_TOKEN_REQUEST_INTERVAL = std::chrono::seconds(60)
static

Max time to wait between attempt to poll for a token while authentication is pending.

◆ MIN_TOKEN_REQUEST_INTERVAL

const std::chrono::seconds alexaClientSDK::authorization::cblAuthDelegate::MIN_TOKEN_REQUEST_INTERVAL = std::chrono::seconds(5)
static

Min time to wait between attempt to poll for a token while authentication is pending.

◆ POST_KEY_CLIENT_ID

const std::string alexaClientSDK::authorization::cblAuthDelegate::POST_KEY_CLIENT_ID = "client_id"
static

client_id key in POST requests to LWA.

◆ POST_KEY_DEVICE_CODE

const std::string alexaClientSDK::authorization::cblAuthDelegate::POST_KEY_DEVICE_CODE = "device_code"
static

device_code key in POST requests to LWA.

◆ POST_KEY_GRANT_TYPE

const std::string alexaClientSDK::authorization::cblAuthDelegate::POST_KEY_GRANT_TYPE = "grant_type"
static

grant_type key in POST requests to LWA.

◆ POST_KEY_REFRESH_TOKEN

const std::string alexaClientSDK::authorization::cblAuthDelegate::POST_KEY_REFRESH_TOKEN = "refresh_token"
static

refresh_token key in POST requests to LWA.

◆ POST_KEY_RESPONSE_TYPE

const std::string alexaClientSDK::authorization::cblAuthDelegate::POST_KEY_RESPONSE_TYPE = "response_type"
static

response_type key in POST requests to LWA.

◆ POST_KEY_SCOPE

const std::string alexaClientSDK::authorization::cblAuthDelegate::POST_KEY_SCOPE = "scope"
static

scope key in POST requests to LWA.

◆ POST_KEY_SCOPE_DATA

const std::string alexaClientSDK::authorization::cblAuthDelegate::POST_KEY_SCOPE_DATA = "scope_data"
static

scope_data key in POST requests to LWA.

◆ POST_KEY_USER_CODE

const std::string alexaClientSDK::authorization::cblAuthDelegate::POST_KEY_USER_CODE = "user_code"
static

user_code key in POST requests to LWA.

◆ POST_VALUE_ALEXA_ALL

const std::string alexaClientSDK::authorization::cblAuthDelegate::POST_VALUE_ALEXA_ALL = "alexa:all"
static

alexa:all value in POST requests to LWA.

◆ POST_VALUE_DEVICE_CODE

const std::string alexaClientSDK::authorization::cblAuthDelegate::POST_VALUE_DEVICE_CODE = "device_code"
static

device_code value in POST requests to LWA.

◆ POST_VALUE_REFRESH_TOKEN

const std::string alexaClientSDK::authorization::cblAuthDelegate::POST_VALUE_REFRESH_TOKEN = "refresh_token"
static

refresh_token value in POST requests to LWA.

◆ TOKEN_REQUEST_SLOW_DOWN_FACTOR

const int alexaClientSDK::authorization::cblAuthDelegate::TOKEN_REQUEST_SLOW_DOWN_FACTOR = 2
static

Scale factor to apply to interval between token poll requests when a 'slow_down' response is received.

AlexaClientSDK 1.26.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0