Skip to content

Commit 40757be

Browse files
committed
Merge pull request #1 from glukacsy/master
Adding proxy support for token_from_code and token_from_refresh methods
2 parents 9683890 + 1e84465 commit 40757be

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

Release/include/cpprest/oauth2.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,24 @@ class oauth2_config
446446
/// Default: "access_token".
447447
/// </summary>
448448
void set_access_token_key(utility::string_t access_token_key) { m_access_token_key = std::move(access_token_key); }
449+
450+
/// <summary>
451+
/// Get the web proxy object
452+
/// </summary>
453+
/// <returns>A reference to the web proxy object.</returns>
454+
const web_proxy& proxy() const
455+
{
456+
return m_proxy;
457+
}
458+
459+
/// <summary>
460+
/// Set the web proxy object that will be used by token_from_code and token_from_refresh
461+
/// </summary>
462+
/// <param name="proxy">A reference to the web proxy object.</param>
463+
void set_proxy(const web_proxy& proxy)
464+
{
465+
m_proxy = proxy;
466+
}
449467

450468
private:
451469
friend class web::http::client::http_client_config;
@@ -483,6 +501,8 @@ class oauth2_config
483501
utility::string_t m_scope;
484502
utility::string_t m_state;
485503

504+
web::web_proxy m_proxy;
505+
486506
bool m_implicit_grant;
487507
bool m_bearer_auth;
488508
bool m_http_basic_auth;

Release/src/http/oauth/oauth2.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "stdafx.h"
2727

2828
using web::http::client::http_client;
29+
using web::http::client::http_client_config;
2930
using web::http::oauth2::details::oauth2_strings;
3031
using web::http::details::mime_types;
3132
using utility::conversions::to_utf8string;
@@ -134,7 +135,11 @@ pplx::task<void> oauth2_config::_request_token(uri_builder& request_body_ub)
134135
}
135136
request.set_body(request_body_ub.query(), mime_types::application_x_www_form_urlencoded);
136137

137-
http_client token_client(token_endpoint());
138+
// configure proxy
139+
http_client_config config;
140+
config.set_proxy(m_proxy);
141+
142+
http_client token_client(token_endpoint(), config);
138143

139144
return token_client.request(request)
140145
.then([](http_response resp)

0 commit comments

Comments
 (0)