Skip to content

Adding proxy support for token_from_code and token_from_refresh methods #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 5, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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