Skip to content

Commit 96da405

Browse files
committed
Include all oauth_ headers in authorization header
Fixes #26
1 parent 2893f1b commit 96da405

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

src/liboauthcpp.cpp

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ namespace Defaults
1313
/* Constants */
1414
const int BUFFSIZE = 1024;
1515
const int BUFFSIZE_LARGE = 1024;
16+
17+
const std::string OAUTH_PARAMETER_PREFIX = "oauth_";
18+
1619
const std::string CONSUMERKEY_KEY = "oauth_consumer_key";
1720
const std::string CALLBACK_KEY = "oauth_callback";
1821
const std::string VERSION_KEY = "oauth_version";
@@ -506,7 +509,7 @@ std::string Client::buildOAuthParameterString(
506509
// request type.
507510
std::string nonce;
508511
std::string timeStamp;
509-
512+
510513
generateNonceTimeStamp(nonce, timeStamp);
511514

512515
/* Build key-value pairs needed for OAuth request token, without signature */
@@ -523,21 +526,11 @@ std::string Client::buildOAuthParameterString(
523526
*/
524527
if (string_type == AuthorizationHeaderString) {
525528
KeyValuePairs oauthKeyValuePairs;
526-
std::vector<std::string> oauth_keys;
527-
oauth_keys.push_back(Defaults::CONSUMERKEY_KEY);
528-
oauth_keys.push_back(Defaults::NONCE_KEY);
529-
oauth_keys.push_back(Defaults::SIGNATURE_KEY);
530-
oauth_keys.push_back(Defaults::SIGNATUREMETHOD_KEY);
531-
oauth_keys.push_back(Defaults::TIMESTAMP_KEY);
532-
oauth_keys.push_back(Defaults::TOKEN_KEY);
533-
oauth_keys.push_back(Defaults::VERIFIER_KEY);
534-
oauth_keys.push_back(Defaults::VERSION_KEY);
535-
536-
for(size_t i = 0; i < oauth_keys.size(); i++) {
537-
assert(rawKeyValuePairs.count(oauth_keys[i]) <= 1);
538-
KeyValuePairs::iterator oauth_key_it = rawKeyValuePairs.find(oauth_keys[i]);
539-
if (oauth_key_it != rawKeyValuePairs.end())
540-
ReplaceOrInsertKeyValuePair(oauthKeyValuePairs, oauth_keys[i], oauth_key_it->second);
529+
for(KeyValuePairs::iterator oauth_keys_it = rawKeyValuePairs.begin(); oauth_keys_it != rawKeyValuePairs.end(); oauth_keys_it++) {
530+
if (oauth_keys_it->first.substr(0, Defaults::OAUTH_PARAMETER_PREFIX.size()) == Defaults::OAUTH_PARAMETER_PREFIX) {
531+
assert(rawKeyValuePairs.count(oauth_keys_it->first) <= 1);
532+
ReplaceOrInsertKeyValuePair(oauthKeyValuePairs, oauth_keys_it->first, oauth_keys_it->second);
533+
}
541534
}
542535
getStringFromOAuthKeyValuePairs( oauthKeyValuePairs, rawParams, separator );
543536
}

0 commit comments

Comments
 (0)