10Duke Enterprise C++ Client
|
#include <OAuthTokenRequest.h>
OAuth token request.
Performs both "exchange-code-to-accesstoken" and "refresh token" requests. Used mostly internally to share common functionality.
Public Member Functions | |
OAuthTokenRequest (std::unique_ptr< tenduke::http::HTTPCall > httpCall, const std::shared_ptr< const tenduke::json::JSONParser > &jsonParser, const std::shared_ptr< tenduke::time::Clock > &clock, const std::shared_ptr< const tenduke::http::HTTPResponseToException > &throwException) | |
Constructs new instance. | |
OAuthTokenRequest (std::unique_ptr< tenduke::http::HTTPCall > httpCall, const std::shared_ptr< const tenduke::json::JSONParser > &jsonParser, const std::shared_ptr< tenduke::time::Clock > &clock) | |
Constructs new instance. | |
virtual std::unique_ptr< tenduke::oauth::OAuthTokenResponse > | execute () const |
Executes the token request. | |
Static Public Member Functions | |
static std::unique_ptr< OAuthTokenRequest > | create (const std::string &tokenEndpointUrl, const std::map< std::string, std::string > ¶meters, const std::shared_ptr< const tenduke::http::HTTPClient > &httpClient, const std::shared_ptr< const tenduke::json::JSONParser > &jsonParser, const std::shared_ptr< tenduke::time::Clock > &clock) |
Factory method to create the request. | |
Protected Member Functions | |
virtual std::unique_ptr< tenduke::json::JSONObject > | parseResponseBody (const std::string &responsePayload) const |
Parses the response body to JSON. | |
virtual std::unique_ptr< tenduke::oauth::OAuthTokenResponse > | toResponse (const std::string &responsePayload) const |
Converts the response body to OAuthTokenResponse. | |
tenduke::oauth::OAuthTokenRequest::OAuthTokenRequest | ( | std::unique_ptr< tenduke::http::HTTPCall > | httpCall, |
const std::shared_ptr< const tenduke::json::JSONParser > & | jsonParser, | ||
const std::shared_ptr< tenduke::time::Clock > & | clock, | ||
const std::shared_ptr< const tenduke::http::HTTPResponseToException > & | throwException | ||
) |
Constructs new instance.
httpCall | the HTTP call to be executed |
jsonParser | For parsing the the response |
clock | for generating "expires-at" from "expires-in" |
throwException | maps HTTP status codes to exceptions |
tenduke::oauth::OAuthTokenRequest::OAuthTokenRequest | ( | std::unique_ptr< tenduke::http::HTTPCall > | httpCall, |
const std::shared_ptr< const tenduke::json::JSONParser > & | jsonParser, | ||
const std::shared_ptr< tenduke::time::Clock > & | clock | ||
) |
Constructs new instance.
Uses default implementation for "throwException".
httpCall | the HTTP call to be executed |
jsonParser | For parsing the the response |
clock | for generating "expires-at" from "expires-in" |
|
virtual |
Executes the token request.
tenduke::oauth::OAuthServerError | when the server responds with an error |
tenduke::oauth::OAuthException | when the server response is not what we expected, e.g.
|
tenduke::json::JSONParsingException | when response is not valid JSON |
tenduke::net::NetworkingException | (or subclasses of it) when networking error occurred, e.g.
|
tenduke::http::HTTPException | (or subclasses of it) when the server responds with HTTP error status code which does not indicate OAuth-error, e.g. 500 (internal server error) or 404 (not found = wrong endpoint configured). |
std::nested_exception | when the there is some nested cause |
Reimplemented in tenduke::test::mocks::OAuthTokenRequestFake.
|
protectedvirtual |
Parses the response body to JSON.
responsePayload | - |
|
protectedvirtual |