@@ -31,14 +31,10 @@ public static string GetAuthorizationHeader(string uri, string method, string pa
3131 { "oauth_nonce" , GetNonce ( ) } ,
3232 { "oauth_timestamp" , GetTimestamp ( ) } ,
3333 { "oauth_signature_method" , "RSA-SHA256" } ,
34- { "oauth_version" , "1.0" }
34+ { "oauth_version" , "1.0" } ,
35+ { "oauth_body_hash" , GetBodyHash ( payload , encoding ) }
3536 } ;
3637
37- if ( ! string . IsNullOrEmpty ( payload ) )
38- {
39- oauthParameters . Add ( "oauth_body_hash" , GetBodyHash ( payload , encoding ) ) ;
40- }
41-
4238 // Compute the OAuth signature
4339 var oauthParamString = GetOAuthParamString ( queryParameters , oauthParameters ) ;
4440 var baseUri = GetBaseUriString ( uri ) ;
@@ -99,8 +95,9 @@ internal static Dictionary<string, List<string>> ExtractQueryParams(string uri)
9995
10096 /// <summary>
10197 /// Generates a hash based on request payload as per https://tools.ietf.org/id/draft-eaton-oauth-bodyhash-00.html.
98+ /// "If the request does not have an entity body, the hash should be taken over the empty string".
10299 /// </summary>
103- internal static string GetBodyHash ( string payload , Encoding encoding ) => Convert . ToBase64String ( Sha256Digest ( payload , encoding ) ) ;
100+ internal static string GetBodyHash ( string payload , Encoding encoding ) => Convert . ToBase64String ( Sha256Digest ( payload ?? string . Empty , encoding ) ) ;
104101
105102 /// <summary>
106103 /// Lexicographically sort all parameters and concatenate them into a string as per https://tools.ietf.org/html/rfc5849#section-3.4.1.3.2.
0 commit comments