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",
"Host": "httpbin.org",
"User-Agent": "1Script v$1.9.2.10",
"X-Amzn-Trace-Id": "Root=1-682cd6ec-50dd82f526c707e106598284"
},
"origin": "***",
"url": "https://httpbin.org/get"
}