Angular-5 StripeConnect -303 Error -Response for Preflight is invalid (Redirect)

933 Views Asked by At

I am doing StripeConnect(Standard Account Type) with Angular 5 and Asp.NetCore. I am able to get redirected to required URL with code={} value. When I am trying to use this code in below URL,

https://connect.stripe.com/oauth/token\client_secret={{secret test key}}\code={{code}}\grant_type = authorization_code"

1.I get preflight is invalid (Redirect) error in browser from my angular solution.

2.The html for stripe login page from Postman.

The code I wrote for making the post call to above URL (in angular) is :

getCredentialsFromStripe(code: any) 
    {
      let Url = "https://connect.stripe.com/oauth/token"; 
                //\client_secret=" + {{key}} + "\code=" + code + "\grant_type 
        = authorization_code";

      return this.http.post(Url, {
        Body: "client_secret = {{key}}\code =" + code,
        Headers: {
              'Authorization': 'Bearer '+ code,
              "Accept": "application/json; charset=UTF-8",
              "Access-Control-Allow-Origin": "https://connect.stripe.com/oauth/token"
      }
   }).map(res => res.json());
}

As per suggestions on internet,I tried making the post call from backend(.NET core(2.0) API for me),but didn't get through in creating account for standard account type.

Moreover testing from postman is giving the full html page of login ,instead of getting this object:

{
  "token_type": "bearer",
  "stripe_publishable_key": "{PUBLISHABLE_KEY}",
  "scope": "read_write",
  "livemode": false,
  "stripe_user_id": "{ACCOUNT_ID}",
  "refresh_token": "{REFRESH_TOKEN}",
  "access_token": "{ACCESS_TOKEN}"
}

Can anybody give me a lead on this.I have been stuck past two days.

Any thoughts will be really appreciated.

1

There are 1 best solutions below

0
On

Well,I was able to fix it. Instead of creating accounts using the URL (given above) in angular project (following the node.js documents),I called the stripe api's in Asp.net core (my api solution) and called them.It worked easily.