Bom dia!!!
Ao solicitar token via Postman, tudo funciona normal. Porém estou tentando solicitar o token via um componente Angular e não estou conseguindo, será que alguem pode me ajudar?
Código:
`
login() {
const headers = new HttpHeaders({Authorization: 'Basic '+btoa('qualidade'+": "+'qualidadepwd')})
const data = {
'scope': 'web',
'grant_type': 'password',
'username': 'Teste',
'password': '123'
};
this.http.post('http://localhost:8088/oauth/token', data, {headers}).subscribe(
res => {
console.log(res)
},
error =>{
console.log(error);
}
);
} ```
ERRO:
headers: HttpHeaders {normalizedNames: Map(0), lazyUpdate: null, headers: Map(0)} status: 0 statusText: "Unknown Error" url: "http://localhost:8088/oauth/token" ok: false name: "HttpErrorResponse" message: "Http failure response for http://localhost:8088/oauth/token: 0 Unknown Error" error: ProgressEvent {isTrusted: true, lengthComputable: false, loaded: 0, total: 0, type: "error", …} proto: HttpResponseBase
*Aba Network browser *
Request URL: http://localhost:8088/oauth/token Referrer Policy: no-referrer-when-downgrade Provisional headers are shown Accept: application/json, text/plain, / Authorization: Basic cXVhbGlkYWRlOiBxdWFsaWRhZGVwd2Q= Content-Type: application/json Referer: http://localhost:4200/ Sec-Fetch-Dest: empty User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36 {scope: "web", grant_type: "password", username: "Teste", password: "123"} scope: "web" grant_type: "password" username: "Teste" password: "123"