HTTPS POST - Angular 19 - Paypal HttpErrorResponse "status: 401, error: 'invalid_token',...

Discussão em 'Angular' iniciado por Stefano Giammori, Março 3, 2025.

  1. My snippets of code

    'payment.service.ts'

    endpoint_url = "https://api-m.sandbox.paypal.com/v1/oauth2/token"

    autenticaService(): Observable<Object> {

    const auth = `${this.client_id}:${this.client_secret}`
    const data = 'grant_type=client_credentials';
    let authString = "Basic " + window.btoa(auth);

    return this.httpClient.post(
    this.endpoint_url, data, { headers: new HttpHeaders({ 'Content-Type': 'application/x-www-form-urlencoded', 'Authorization': `${authString}` }) } ).pipe(
    map(
    data => {
    console.log(data);
    //this.storageService.setItem("Utente", username);
    //this.cookieService.set("AuthToken", `Bearer ${data.token}`);
    return data;
    }
    ))
    }

    'shoppingcart.component.ts'

    acquista = () => {
    this.paymentService.autenticaService().subscribe(
    body => console.log(body));
    }

    I receive a {"HttpErrorResponse status: 401, error: 'invalid_token', error_description: 'Token signature verification failed'} ... where i'm wrong ?? The token is what i need in this case.. but it was the request for the token.. so..

    Continue reading...

Compartilhe esta Página