C++ Rest SDK
The C++ REST SDK is a Microsoft project for cloud-based client-server communication in native code using a modern asynchronous C++ API design. This project aims to help C++ developers connect to and interact with services.
Public Member Functions | Friends | List of all members
web::http::oauth1::experimental::oauth1_config Class Reference

OAuth 1.0 configuration class. More...

#include <oauth1.h>

Public Member Functions

 oauth1_config (utility::string_t consumer_key, utility::string_t consumer_secret, utility::string_t temp_endpoint, utility::string_t auth_endpoint, utility::string_t token_endpoint, utility::string_t callback_uri, oauth1_method method, utility::string_t realm=utility::string_t())
 
_ASYNCRTIMP pplx::task< utility::string_t > build_authorization_uri ()
 Builds an authorization URI to be loaded in a web browser/view. The URI is built with auth_endpoint() as basis. The method creates a task for HTTP request to first obtain a temporary token. The authorization URI build based on this token. More...
 
_ASYNCRTIMP pplx::task< void > token_from_redirected_uri (const web::http::uri &redirected_uri)
 Fetch an access token based on redirected URI. The URI is expected to contain 'oauth_verifier' parameter, which is then used to fetch an access token using the token_from_verifier() method. See: http://tools.ietf.org/html/rfc5849#section-2.2 The received 'oauth_token' is parsed and verified to match the current token(). When access token is successfully obtained, set_token() is called, and config is ready for use by oauth1_handler. More...
 
pplx::task< void > token_from_verifier (utility::string_t verifier)
 Creates a task with HTTP request to fetch an access token from the token endpoint. The request exchanges a verifier code to an access token. If successful, the resulting token is set as active via set_token(). See: http://tools.ietf.org/html/rfc5849#section-2.3 More...
 
pplx::task< void > refresh_token (const utility::string_t &key)
 Creates a task with HTTP request to fetch an access token from the token endpoint. If successful, the resulting token is set as active via set_token(). More...
 
const utility::string_t & consumer_key () const
 Get consumer key used in authorization and authentication. More...
 
void set_consumer_key (utility::string_t key)
 Set consumer key used in authorization and authentication. More...
 
const utility::string_t & consumer_secret () const
 Get consumer secret used in authorization and authentication. More...
 
void set_consumer_secret (utility::string_t secret)
 Set consumer secret used in authorization and authentication. More...
 
const utility::string_t & temp_endpoint () const
 Get temporary token endpoint URI string. More...
 
void set_temp_endpoint (utility::string_t temp_endpoint)
 Set temporary token endpoint URI string. More...
 
const utility::string_t & auth_endpoint () const
 Get authorization endpoint URI string. More...
 
void set_auth_endpoint (utility::string_t auth_endpoint)
 Set authorization endpoint URI string. More...
 
const utility::string_t & token_endpoint () const
 Get token endpoint URI string. More...
 
void set_token_endpoint (utility::string_t token_endpoint)
 Set token endpoint URI string. More...
 
const utility::string_t & callback_uri () const
 Get callback URI string. More...
 
void set_callback_uri (utility::string_t callback_uri)
 Set callback URI string. More...
 
_ASYNCRTIMP const oauth1_tokentoken () const
 Get token. More...
 
void set_token (oauth1_token token)
 Set token. More...
 
const oauth1_methodmethod () const
 Get signature method. More...
 
void set_method (oauth1_method method)
 Set signature method. More...
 
const utility::string_t & realm () const
 Get authentication realm. More...
 
void set_realm (utility::string_t realm)
 Set authentication realm. More...
 
bool is_enabled () const
 Returns enabled state of the configuration. The oauth1_handler will perform OAuth 1.0 authentication only if this method returns true. Return value is true if access token is valid (=fetched or manually set) and both consumer_key() and consumer_secret() are set (=non-empty). More...
 
_ASYNCRTIMP utility::string_t _build_signature_base_string (http_request request, details::oauth1_state state) const
 
utility::string_t _build_hmac_sha1_signature (http_request request, details::oauth1_state state) const
 
utility::string_t _build_plaintext_signature () const
 
details::oauth1_state _generate_auth_state (utility::string_t extra_key, utility::string_t extra_value)
 
details::oauth1_state _generate_auth_state ()
 
const std::map< utility::string_t, utility::string_t > & parameters () const
 Gets map of parameters to sign. More...
 
void add_parameter (const utility::string_t &key, const utility::string_t &value)
 Adds a key value parameter. More...
 
void add_parameter (utility::string_t &&key, utility::string_t &&value)
 Adds a key value parameter. More...
 
void set_parameters (const std::map< utility::string_t, utility::string_t > &parameters)
 Sets entire map or parameters replacing all previously values. More...
 
void clear_parameters ()
 Clears all parameters. More...
 

Friends

class web::http::client::http_client_config
 
class web::http::oauth1::details::oauth1_handler
 

Detailed Description

OAuth 1.0 configuration class.

Member Function Documentation

void web::http::oauth1::experimental::oauth1_config::add_parameter ( const utility::string_t &  key,
const utility::string_t &  value 
)
inline

Adds a key value parameter.

Parameters
keyKey as a string value.
valueValue as a string value.
void web::http::oauth1::experimental::oauth1_config::add_parameter ( utility::string_t &&  key,
utility::string_t &&  value 
)
inline

Adds a key value parameter.

Parameters
keyKey as a string value.
valueValue as a string value.
const utility::string_t& web::http::oauth1::experimental::oauth1_config::auth_endpoint ( ) const
inline

Get authorization endpoint URI string.

Returns
Authorization endpoint URI string.
_ASYNCRTIMP pplx::task<utility::string_t> web::http::oauth1::experimental::oauth1_config::build_authorization_uri ( )

Builds an authorization URI to be loaded in a web browser/view. The URI is built with auth_endpoint() as basis. The method creates a task for HTTP request to first obtain a temporary token. The authorization URI build based on this token.

Returns
Authorization URI to be loaded in a web browser/view.
const utility::string_t& web::http::oauth1::experimental::oauth1_config::callback_uri ( ) const
inline

Get callback URI string.

Returns
Callback URI string.
void web::http::oauth1::experimental::oauth1_config::clear_parameters ( )
inline

Clears all parameters.

const utility::string_t& web::http::oauth1::experimental::oauth1_config::consumer_key ( ) const
inline

Get consumer key used in authorization and authentication.

Returns
Consumer key string.
const utility::string_t& web::http::oauth1::experimental::oauth1_config::consumer_secret ( ) const
inline

Get consumer secret used in authorization and authentication.

Returns
Consumer secret string.
bool web::http::oauth1::experimental::oauth1_config::is_enabled ( ) const
inline

Returns enabled state of the configuration. The oauth1_handler will perform OAuth 1.0 authentication only if this method returns true. Return value is true if access token is valid (=fetched or manually set) and both consumer_key() and consumer_secret() are set (=non-empty).

Returns
The configuration enabled state.
const oauth1_method& web::http::oauth1::experimental::oauth1_config::method ( ) const
inline

Get signature method.

Returns
Signature method.
const std::map<utility::string_t, utility::string_t>& web::http::oauth1::experimental::oauth1_config::parameters ( ) const
inline

Gets map of parameters to sign.

Returns
Map of parameters.
const utility::string_t& web::http::oauth1::experimental::oauth1_config::realm ( ) const
inline

Get authentication realm.

Returns
Authentication realm string.
pplx::task<void> web::http::oauth1::experimental::oauth1_config::refresh_token ( const utility::string_t &  key)
inline

Creates a task with HTTP request to fetch an access token from the token endpoint. If successful, the resulting token is set as active via set_token().

Returns
Task that fetches the access token based on the verifier.
void web::http::oauth1::experimental::oauth1_config::set_auth_endpoint ( utility::string_t  auth_endpoint)
inline

Set authorization endpoint URI string.

Parameters
auth_endpointAuthorization endpoint URI string to set.
void web::http::oauth1::experimental::oauth1_config::set_callback_uri ( utility::string_t  callback_uri)
inline

Set callback URI string.

Parameters
callback_uriCallback URI string to set.
void web::http::oauth1::experimental::oauth1_config::set_consumer_key ( utility::string_t  key)
inline

Set consumer key used in authorization and authentication.

Parameters
keyConsumer key string to set.
void web::http::oauth1::experimental::oauth1_config::set_consumer_secret ( utility::string_t  secret)
inline

Set consumer secret used in authorization and authentication.

Parameters
secretConsumer secret string to set.
void web::http::oauth1::experimental::oauth1_config::set_method ( oauth1_method  method)
inline

Set signature method.

Parameters
methodSignature method.
void web::http::oauth1::experimental::oauth1_config::set_parameters ( const std::map< utility::string_t, utility::string_t > &  parameters)
inline

Sets entire map or parameters replacing all previously values.

Parameters
parametersMap of values.
void web::http::oauth1::experimental::oauth1_config::set_realm ( utility::string_t  realm)
inline

Set authentication realm.

Parameters
realmAuthentication realm string to set.
void web::http::oauth1::experimental::oauth1_config::set_temp_endpoint ( utility::string_t  temp_endpoint)
inline

Set temporary token endpoint URI string.

Parameters
temp_endpointTemporary token endpoint URI string to set.
void web::http::oauth1::experimental::oauth1_config::set_token ( oauth1_token  token)
inline

Set token.

Parameters
tokenToken to set.
void web::http::oauth1::experimental::oauth1_config::set_token_endpoint ( utility::string_t  token_endpoint)
inline

Set token endpoint URI string.

Parameters
token_endpointToken endpoint URI string to set.
const utility::string_t& web::http::oauth1::experimental::oauth1_config::temp_endpoint ( ) const
inline

Get temporary token endpoint URI string.

Returns
Temporary token endpoint URI string.
_ASYNCRTIMP const oauth1_token& web::http::oauth1::experimental::oauth1_config::token ( ) const

Get token.

Returns
Token.
const utility::string_t& web::http::oauth1::experimental::oauth1_config::token_endpoint ( ) const
inline

Get token endpoint URI string.

Returns
Token endpoint URI string.
_ASYNCRTIMP pplx::task<void> web::http::oauth1::experimental::oauth1_config::token_from_redirected_uri ( const web::http::uri redirected_uri)

Fetch an access token based on redirected URI. The URI is expected to contain 'oauth_verifier' parameter, which is then used to fetch an access token using the token_from_verifier() method. See: http://tools.ietf.org/html/rfc5849#section-2.2 The received 'oauth_token' is parsed and verified to match the current token(). When access token is successfully obtained, set_token() is called, and config is ready for use by oauth1_handler.

Parameters
redirected_uriThe URI where web browser/view was redirected after resource owner's authorization.
Returns
Task that fetches the access token based on redirected URI.
pplx::task<void> web::http::oauth1::experimental::oauth1_config::token_from_verifier ( utility::string_t  verifier)
inline

Creates a task with HTTP request to fetch an access token from the token endpoint. The request exchanges a verifier code to an access token. If successful, the resulting token is set as active via set_token(). See: http://tools.ietf.org/html/rfc5849#section-2.3

Parameters
verifierVerifier received via redirect upon successful authorization.
Returns
Task that fetches the access token based on the verifier.

The documentation for this class was generated from the following file: