Skip to content

Commit

Permalink
Merge pull request #1 from glukacsy/master
Browse files Browse the repository at this point in the history
Adding proxy support for token_from_code and token_from_refresh methods
  • Loading branch information
kavyako committed Nov 5, 2015
2 parents 9683890 + 1e84465 commit 40757be
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
20 changes: 20 additions & 0 deletions Release/include/cpprest/oauth2.h
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,24 @@ class oauth2_config
/// Default: "access_token".
/// </summary>
void set_access_token_key(utility::string_t access_token_key) { m_access_token_key = std::move(access_token_key); }

/// <summary>
/// Get the web proxy object
/// </summary>
/// <returns>A reference to the web proxy object.</returns>
const web_proxy& proxy() const
{
return m_proxy;
}

/// <summary>
/// Set the web proxy object that will be used by token_from_code and token_from_refresh
/// </summary>
/// <param name="proxy">A reference to the web proxy object.</param>
void set_proxy(const web_proxy& proxy)
{
m_proxy = proxy;
}

private:
friend class web::http::client::http_client_config;
Expand Down Expand Up @@ -483,6 +501,8 @@ class oauth2_config
utility::string_t m_scope;
utility::string_t m_state;

web::web_proxy m_proxy;

bool m_implicit_grant;
bool m_bearer_auth;
bool m_http_basic_auth;
Expand Down
7 changes: 6 additions & 1 deletion Release/src/http/oauth/oauth2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "stdafx.h"

using web::http::client::http_client;
using web::http::client::http_client_config;
using web::http::oauth2::details::oauth2_strings;
using web::http::details::mime_types;
using utility::conversions::to_utf8string;
Expand Down Expand Up @@ -134,7 +135,11 @@ pplx::task<void> oauth2_config::_request_token(uri_builder& request_body_ub)
}
request.set_body(request_body_ub.query(), mime_types::application_x_www_form_urlencoded);

http_client token_client(token_endpoint());
// configure proxy
http_client_config config;
config.set_proxy(m_proxy);

http_client token_client(token_endpoint(), config);

return token_client.request(request)
.then([](http_response resp)
Expand Down

0 comments on commit 40757be

Please sign in to comment.