Hello everyone,
i am trying to call openhab api from a local angular project using the api token (oauth2).
As soon as I make the call, a popup comes out in the browser asking me for my credentials (username and password) to authenticate me.
I do not understand if it is a mandatory step, or if I am wrong to send the token in the call (I would not like to have to enter the credentials every time to authenticate but do it through the API token).
It seems like the only way you can authenticate is with Basic Auth.
Is there a way to authenticate api calls only with token ?
I put below the code with which I make the call.
const httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json',
'Authorization': `Bearer oh.API.....`
})
};
return this.http.get<any[]>('https://home.myopenhab.org/rest/items', httpOptions).subscribe(response => {
this.result = JSON.stringify(response)
this.isError = false;
}, error => {
this.result = JSON.stringify(error);
this.isError = true;
})
}
type or paste code here