Add Bearer authorization
Adds a request header for Bearer authorization
Function AddBearerAuthorization(Val Token) Export
Parameter | CLI option | Type | Required | Description |
---|---|---|---|---|
Token | --token | String | ✔ | Bearer token value |
Returns: DataProcessorObject.OPI_HTTPClient - This processor object
1C:Enterprise/OneScript code example
URL = "https://httpbin.org";
URL = URL + "/get";
Result = OPI_HTTPRequests.NewRequest()
.Initialize()
.SetURL(URL)
.AddBearerAuthorization("123123") // <---
.ProcessRequest("GET")
.ReturnResponseAsJSONObject();
Result
{
"args": {},
"headers": {
"Accept": "*/*",
"Accept-Charset": "utf-8",
"Accept-Encoding": "gzip",
"Authorization": "Bearer 123123",
"Content-Length": "0",
"Host": "httpbin.org",
"User-Agent": "1Script v$2.0.0.0",
"X-Amzn-Trace-Id": "Root=1-68c8adaf-73e793297f4d579a05a12676"
},
"origin": "***",
"url": "https://httpbin.org/get"
}