Add OAuth V1 authorization
Adds data for OAuth v1 authorization
Function AddOAuthV1Authorization(Val Token, Val Secret, Val ConsumerKey, Val ConsumerSecret, Val Version) Export
Parameter | CLI option | Type | Required | Description |
---|---|---|---|---|
Token | --token | String | ✔ | Token for authorization |
Secret | --secret | String | ✔ | Secret for authorization |
ConsumerKey | --ck | String | ✔ | Consumer key for authorization |
ConsumerSecret | --cs | String | ✔ | Consumer secret for authorization |
Version | --ver | String | ✔ | API version |
Returns: DataProcessorObject.OPI_HTTPClient - This processor object
tip
By default, HMAC-SHA256 is used to create the signature. To change the algorithm, you can use SetOAuthV1Algorithm
1C:Enterprise/OneScript code example
URL = "https://httpbin.org";
URL = URL + "/get";
Token = "***";
Secret = "***";
UsersKey = "***";
UsersSecret = "***";
Version = "1.0";
Result = OPI_HTTPRequests.NewRequest()
.Initialize(URL)
.AddOAuthV1Authorization(Token, Secret, UsersKey, UsersSecret, Version) // <---
.ProcessRequest("GET")
.ReturnResponseAsJSONObject();
Result
{
"args": {},
"headers": {
"Accept": "*/*",
"Accept-Charset": "utf-8",
"Accept-Encoding": "gzip",
"Authorization": "OAuth oauth_consumer_key=\"***\",oauth_token=\"***\",oauth_signature_method=\"HMAC-SHA256\",oauth_timestamp=\"1747776272\",oauth_nonce=\"1747776272\",oauth_version=\"1.0\",oauth_signature=JQywSUMcV3Ssix74DbLTw65yQkxQm1rb2KkuHsrRedU%3D",
"Host": "httpbin.org",
"User-Agent": "1Script v$1.9.2.10",
"X-Amzn-Trace-Id": "Root=1-682cd6f0-17e2b7d802ff2fba5493c829"
},
"origin": "***",
"url": "https://httpbin.org/get"
}