'How to generate oauth_signature in C#

I'm trying to call an API which was associated with OAuth 1.0 version. From the postman wen I tried by passing the header param "Authorization" It's value is as follows :

OAuth realm="realm1",
oauth_consumer_key="oauth_consumer_key1",
oauth_token="oauth_token1",
oauth_signature_method="HMAC-SHA256",
oauth_timestamp="1607936624",
oauth_nonce="vWZBL6a34T",
oauth_version="1.0",
oauth_signature="0md4Tg9wqa4DZV9VGwtvwPeb0ojZoRr0j6pR00HTu1I%3D"

From the above key value pairs:

oauth_signature
oauth_timestamp
oauth_nonce

These 3 are generating dynamically, Which I had observed in postman. How can I generate these 3 in C# code dynamically ?



Solution 1:[1]

You can use OAuth library to generate authorization header.

OAuthRequest client = OAuthRequest.ForProtectedResource("HTTP_METHOD", "CONSUMER_KEY", "CONSUMER_SECRET", "ACCESS_TOKEN", "ACCESS_TOKEN_SECRET");
client.RequestUrl = "REQUEST_URL";

string auth = client.GetAuthorizationHeader();

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ropra