title: Problem generating signature with OAuth 1.0
body: <p>I am having a problem generating a valid HMAC-SHA1 signature in powershell which I eventually would like to use with the Flickr API.  I have been stuck on this for a couple of weeks, so if somebody please tell me what I a doing wrong, that would be much appreciated.  Thank you :)</p>
  <p>Here is the code I have written:</p>
  <pre><code>$oauth_signature_method = 'HMAC-SHA1'
  [string]$oauth_nonce    = New-Guid   
  [int]$oauth_timestamp   = [int](Get-Date -UFormat %s -Millisecond 0) 
  $oauth_version          = '1.0' 
  $oauth_consumer_key     = 'e1d618f39j69s6a87443b182a1e91084' #NOT REAL KEY
  $oauth_consumer_secret  = 'dd6jjff7423acb3a' # NOT REAL KEY
  $url                    = 'https://www.flickr.com/services/oauth/request_token'
  $method                 = 'GET'
  $oauth_callback         = 'oob'
      
  $signature_key          = [System.Uri]::EscapeDataString($oauth_consumer_key)+&quot;&amp;&quot;+[System.Uri]::EscapeDataString($oauth_consumer_secret);
  $method                 = $method.ToUpper()
  
  $response=&quot;&quot;
  $oauth_signature = &quot;&quot;
  
  # Build the signature
  $SignatureBase = &quot;$([System.Uri]::EscapeDataString($url))&amp;&quot;
              
  $SignatureParams = @{
                  'oauth_callback'         = [System.Web.HttpUtility]::UrlEncode($oauth_callback);
                  'oauth_consumer_key'     = $oauth_consumer_key;
                  'oauth_nonce'            = $oauth_nonce.replace(&quot;-&quot;,&quot;&quot;);
                  'oauth_signature_method' = $oauth_signature_method;
                  'oauth_timestamp'        = $oauth_timestamp;
                  'oauth_version'          = $oauth_version;
              }   
  
  $SignatureParams.GetEnumerator() | Sort Name |foreach { $SignatureBase += [System.Uri]::EscapeDataString(&quot;$($_.Key)=$($_.Value)&amp;&quot;) }
  
  $SignatureBase = [System.Uri]::EscapeDataString(&quot;$method&amp;&quot;)+$SignatureBase.TrimEnd('%26')
  
  
  $SignatureBase = [System.Uri]::EscapeDataString($SignatureBase)
  
  ########################################################################################
  # At this point:
  # $SignatureBase = GET%2526https%253A%252F%252Fwww.flickr.com%252Fservices%252Foauth%252Frequest_token%26oauth_callback%253Doob%2526oauth_consumer_key%253De1d618f39j69s6a87443b182a1e91084%2526oauth_nonce%253D080a4203ff7e428bb898086dd
  13a6697%2526oauth_signature_method%253DHMAC-SHA1%2526oauth_timestamp%253D1615550853%2526oauth_version%253D1.0
  # $Signature_key = e1d618f39j69s6a87443b182a1e91084&amp;dd6jjff7423acb3a
  ########################################################################################
  
  $hmac = New-Object System.Security.Cryptography.HMACSHA1
  $hmac.key  = [System.Text.Encoding]::UTF8.GetBytes($Signature_key)
  
  $oauth_signature = $hmac.ComputeHash([System.Text.Encoding]::UTF8.GetBytes($SignatureBase));
  $oauth_signature = [System.Convert]::ToBase64String($oauth_signature) 
  
  ########################################################################################
  # At this point, $oauth_signature = tcKfNZmmRsGhnMmBaIuxRIINJfI=
  ########################################################################################
  
  #Add the signature into the hashtable   
  $SignatureParams += @{'oauth_signature'=$oauth_Signature}       
    
  # Reconstruct the URL to include the new signature
  $callurl = $url+&quot;?&quot;
  $SignatureParams.GetEnumerator() | Sort Name | foreach { $callurl += &quot;$($_.Key)=$($_.Value)&amp;&quot; }
  $callurl = $callurl.TrimEnd('&amp;')
  
  ########################################################################################
  # At this point, this is the URL to get a token:
  # https://www.flickr.com/services/oauth/request_token?oauth_callback=oob&amp;oauth_consumer_key=e1d618f39j69s6a87443b182a1e91084&amp;oauth_nonce=080a4203ff7e428bb898086dd13a6697&amp;oauth_signature=tcKfNZmmRsGhnMmBaIuxRIINJfI=&amp;o
  auth_signature_method=HMAC-SHA1&amp;oauth_timestamp=1615550853&amp;oauth_version=1.0
  ########################################################################################
  
  # Send the request to the oAuth server
  try {$response = Invoke-RestMethod -uri $callurl -method $method -Headers $APIHeader}
  </code></pre>
  <p>When the signature is sent to Flickr, the server rejects it, stating &quot;oauth_problem=signature_invalid&quot;.</p>
  <p>Am I missing a step?</p>
  <p>Thanks.</p>