@@ -283,42 +283,40 @@ std::string GenerateAuthorizationHeader(
283283 time_t timestamp, std::string nonce) {
284284 const std::string timestamp_str = std::to_string (timestamp);
285285
286- std::stringstream stream ;
286+ std::stringstream query ;
287287
288- stream << kOauthConsumerKey << kParamEquals << credentials.GetKey ()
288+ query << kOauthConsumerKey << kParamEquals << credentials.GetKey ()
289289 << kParamAdd << kOauthNonce << kParamEquals << nonce << kParamAdd
290290 << kOauthSignatureMethod << kParamEquals << kHmac << kParamAdd
291291 << kOauthTimestamp << kParamEquals << timestamp_str << kParamAdd
292292 << kOauthVersion << kParamEquals << kVersion ;
293293
294- const auto encoded_query = utils::Url::Encode (stream .str ());
294+ const auto encoded_query = utils::Url::Encode (query .str ());
295295
296- stream. clear () ;
296+ std::stringstream signature_base ;
297297
298- stream << kOauthPost << kParamAdd << utils::Url::Encode (url) << kParamAdd
298+ signature_base << kOauthPost << kParamAdd << utils::Url::Encode (url) << kParamAdd
299299 << encoded_query;
300300
301- const auto signature_base = stream.str ();
302-
303- stream.clear ();
304-
305301 const std::string encode_key = credentials.GetSecret () + kParamAdd ;
306- auto hmac_result = Crypto::hmac_sha256 (encode_key, signature_base);
302+ auto hmac_result = Crypto::hmac_sha256 (encode_key, signature_base. str () );
307303 auto signature = Base64Encode (hmac_result);
308304
309- stream << " OAuth " << kOauthConsumerKey << kParamEquals << kParamQuote
310- << utils::Url::Encode (credentials.GetKey ()) << kParamQuote
311- << kParamComma << kOauthNonce << kParamEquals << kParamQuote
312- << utils::Url::Encode (nonce) << kParamQuote << kParamComma
313- << kOauthSignatureMethod << kParamEquals << kParamQuote << kHmac
314- << kParamQuote << kParamComma << kOauthTimestamp << kParamEquals
315- << kParamQuote << utils::Url::Encode (timestamp_str) << kParamQuote
316- << kParamComma << kOauthVersion << kParamEquals << kParamQuote
317- << kVersion << kParamQuote << kParamComma << kOauthSignature
318- << kParamEquals << kParamQuote << utils::Url::Encode (signature)
319- << kParamQuote ;
320-
321- return stream.str ();
305+ std::stringstream authorization;
306+
307+ authorization << " OAuth " << kOauthConsumerKey << kParamEquals << kParamQuote
308+ << utils::Url::Encode (credentials.GetKey ()) << kParamQuote
309+ << kParamComma << kOauthNonce << kParamEquals << kParamQuote
310+ << utils::Url::Encode (nonce) << kParamQuote << kParamComma
311+ << kOauthSignatureMethod << kParamEquals << kParamQuote << kHmac
312+ << kParamQuote << kParamComma << kOauthTimestamp << kParamEquals
313+ << kParamQuote << utils::Url::Encode (timestamp_str)
314+ << kParamQuote << kParamComma << kOauthVersion << kParamEquals
315+ << kParamQuote << kVersion << kParamQuote << kParamComma
316+ << kOauthSignature << kParamEquals << kParamQuote
317+ << utils::Url::Encode (signature) << kParamQuote ;
318+
319+ return authorization.str ();
322320}
323321
324322} // namespace authentication
0 commit comments