@bates-solutions/stripe API Reference - v2.2.1
    Preparing search index...

    Class OAuthService

    Connect OAuth service: finish the connect flow and disconnect accounts.

    These calls authenticate with your platform's secret key, so they always go out as the platform, even on a client returned by forAccount.

    // OAuth redirect handler. First check `state`: require a stored value,
    // delete it (one use), then compare it with the query value. Then handle a
    // deny (`error=access_denied`, no `code`) and require `code` to be a
    // string. See docs/guides/core/connect.md.
    const { stripeUserId } = await stripe.oauth.exchangeCode(code);
    await db.saveRetailer({ stripeAccountId: stripeUserId });

    // Later, act as the connected account
    const retailer = stripe.forAccount(stripeUserId);
    const { data: products } = await retailer.products.list({ active: true });
    Index
    • Parameters

      • getClient: () => Stripe

        Returns an SDK client authenticated as the platform (no Stripe-Account header)

      • OptionaldefaultClientId: string

        Connect client ID used by deauthorize when the call doesn't pass one

      Returns OAuthService

    • Disconnect a connected account from your platform. Your platform can no longer act on it afterwards.

      Parameters

      Returns Promise<void>

      When stripeUserId is missing, or no client ID is passed or configured

      When Stripe does not confirm the account

      await stripe.oauth.deauthorize(retailer.stripeAccountId);