Dear all.
I am trying to run the protocol from a web browser with this flow.
1, Get a Bearer token issued by the Hub using Basic Authentication.
According to this..
https://{Hub-Server}:9953/foundation/hub/doc/security
Login
POST api/v1/security/login
{
"client_id": "foundation-hub",
"username" : "scitegicadmin",
"password" : "xxxxxx"
}Response:
{
"access_token": "708e37e0-3723-460f-a041-847d35f3ab16",
"token_type": "bearer",
"expires_in": 28799
}| Property | Description | Provided |
|---|---|---|
| access_token | Access token to send when acting on behalf of the user | always |
| token_type | Access token type. Only "bearer" is currently supported | always |
| expires_in | The lifetime in seconds of the access token | always |
2, Execute Protocols with Token
According to this..
https://{PLP-Server}:9943/scitegic-bin/DownloadFile/filenameapps/scitegic/integration/docs/client_side/client_rest.pdf
In jQuery.
\\\$.ajax(
"https://:/Protocols/Web Services/Examples/Generic/Binary Operation Calculator",
{
headers: { "Authorization": "Bearer 708e37e0-3723-460f-a041-847d35f3ab16" },
success: function (data, textStatus, jqXHR) {
console.log(textStatus + ": " + data);
}
}
)In fetch.
async function startFetching() {
const res = await fetch(
"https://:/Protocols/Web Services/Examples/Generic/Binary Operation Calculator",
{
method: "GET",
headers: { "Authorization": "Bearer 708e37e0-3723-460f-a041-847d35f3ab16" }
}
);
const json = await res.json();
}
startFetching();In axios.
import axios from 'axios';
async function startAxios() {
try {
const res = await axios.get(
"https://:/Protocols/Web Services/Examples/Generic/Binary Operation Calculator",
{
headers: { "Authorization": "Bearer 708e37e0-3723-460f-a041-847d35f3ab16" }
}
);
console.log("res");
console.log(res);
} catch (err) {
console.log("err");
console.log(err);
}
}
startAxios();
They all returned "Request failed with status code 401".
I thought the token might be wrong, so I set the parameters of the HTTP Connector component, but this did not change the result.
"Authentication Method" = "Use Authentication Token Parameter".
Since you have already logged in to BIOVIA at the Hub, you should have all the necessary information.
Does anyone have any insight into this strange phenomenon?
Any comments would be appreciated!
