umijs / umi-request

A request tool based on fetch.
2.21k stars 335 forks source link

AADSTS9002326: Cross-origin token redemption is permitted only for the 'Single-Page Application' #299

Open xXAvoraXx opened 2 years ago

xXAvoraXx commented 2 years ago

Hello, I'm trying to get access tokens on localhost but I'm getting the following error.

400 Bad Request

{"error":"invalid_request","error_description":"AADSTS9002326: Cross-origin token redemption is permitted only for the 'Single-Page Application' client-type.\r\nTrace ID: 0c7f2993-b612-434d-9cee-244e88f51600\r\nCorrelation ID: 45d80262-c77f-487b-a95b-4566c736e1bc\r\nTimestamp: 2022-06-07 19:14:30Z","error_codes":[9002326],"timestamp":"2022-06-07 19:14:30Z","trace_id":"0c7f2993-b612-434d-9cee-244e88f51600","correlation_id":"45d80262-c77f-487b-a95b-4566c736e1bc","error_uri":"https://login.windows.net/error?code=9002326"}

  async getPaymentAccessToken() {
    const msg = await request<PaymentAccessTokenResponse>(`/payment/accesstoken/get`, {
      method: 'POST',
      prefix: undefined,
      credentials: 'include',
      headers: {
        client_id: this.client.client_id,
        client_secret: this.client.client_secret,
        'Ocp-Apim-Subscription-Key': this.client['payment-Subscription-Key'],
        'Merchant-Serial-Number': this.client['Merchant-Serial-Number']!,
      },
    });

    return msg;
  }
-----------------------------
Proxy
    '/payment': {
      target: 'https://apitest.domain.com',
      changeOrigin: true,
      secure: false,
      pathRewrite: { '^/payment': '' },
    },