Generate Signature in VB.NET for request_token


#1

Hi

I believe I have everything I need now but I can’t generate the signature correctly. I have used Postman and everything works, if I move the header produced by Postman into my code it works.

I have been using the code below, can any tell me if this is wrong?

Dim str_oauth_signature As String = String.Empty

Dim str_base_format As String = “oauth_consumer_key={0}&oauth_nonce={1}&oauth_signature_method={2}&oauth_timestamp={3}&oauth_token={4}&oauth_version={5}”

Dim str_base = String.Format(str_base_format,
oauth_consumer_key,
oauth_nonce,
oauth_signature_method,
oauth_timestamp,
oauth_token,
oauth_version)

str_base = String.Concat(“POST&”, Uri.EscapeDataString(str_url), “&”, Uri.EscapeDataString(str_base))

Dim str_composite_key As String = String.Concat(Uri.EscapeDataString(oauth_consumer_secret), “&”, Uri.EscapeDataString(oauth_token_secret))

Dim hasher As HMACSHA1 = New HMACSHA1(ASCIIEncoding.ASCII.GetBytes(str_composite_key))

    Using hasher
        str_oauth_signature = Convert.ToBase64String(hasher.ComputeHash(ASCIIEncoding.ASCII.GetBytes(str_base)))
    End Using