Problem with authorization by Bearer in Angular 8 and QT [duplicate]

I have a problem with authorization using the Bearer code.

  getClients(page: number, size: any, session_id: any): Observable<any> {
    let header = new HttpHeaders()
      .append('Access-Control-Allow-Origin', '*')
      .append('Content-Type', 'application/json')
      .append('Accept', 'application/json')
      .append('Authorization', `Bearer ${localStorage.getItem('session_id')}`);

    return this.http.get(`${this.apiUrl}get_clients?page[number]=${page}&page[size]=${size}`,
      {
        responseType: 'json',
        headers: header,
      });
  }

Qt code corsy what are

 p->socket->setHeader(QString("Allow").toLocal8Bit(),QString("GET, POST, OPTIONS").toLocal8Bit());
    p->socket->setHeader(QString("Access-Control-Allow-Origin").toLocal8Bit(),QString("*").toLocal8Bit());
    p->socket->setHeader(QString("Access-Control-Allow-Methods").toLocal8Bit(),QString("GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS").toLocal8Bit());
    p->socket->setHeader(QString("Access-Control-Allow-Headers").toLocal8Bit(),QString("Content-Type, Origin, Accept, Authorization, Content-Length, X-Requested-With").toLocal8Bit());

After a successful place, a key is generated for me until I keep in the session, but it does not work on the corsy that the server sells so

OPTIONS /get_clients?page[number]=1&page[size]=50 HTTP/1.1
Host: 77.55.222.213:22111
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:88.0) Gecko/20100101 Firefox/88.0
Accept: /
Accept-Language: pl,en-US;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate
Access-Control-Request-Method: GET
Access-Control-Request-Headers: access-control-allow-origin,authorization,content-type
Referer: http://localhost:4200/
Origin: http://localhost:4200
Connection: keep-alive

But the appearance looks like the picture.
How do I share the message that I have a token together with Authorization: Bearer software-name for the server in QT Creator.
In Postman it works, I log in, I copy the key and paste it into the Authorization bearer token and it works normally there.

Source: Angular Questions

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.