@bates-solutions/clover API Reference - v1.3.0
    Preparing search index...

    Class CloverOAuthClient

    OAuth client for the app-credential endpoints: exchanging an authorization code and refreshing an expiring token pair (Clover v2 OAuth, high-trust code flow).

    These endpoints authenticate with the app's clientId / clientSecret, not a merchant token, which is why this is separate from CloverClient.

    const oauth = createCloverOAuthClient({
    clientId: process.env.CLOVER_APP_ID!,
    clientSecret: process.env.CLOVER_APP_SECRET!,
    environment: 'production',
    });

    // In the redirect handler, after verifying `state`
    const tokens = await oauth.obtainToken({ code: req.query.code });
    const clover = createCloverClient({
    apiToken: tokens.accessToken,
    merchantId: req.query.merchant_id,
    environment: 'production',
    });
    Index
    • Exchange the authorization code from the OAuth redirect for an expiring token pair.

      Parameters

      • options: { code: string }
        • code: string

          code query parameter from the redirect

      Returns Promise<OAuthTokens>

      const { accessToken, refreshToken, expiresAt } =
      await oauth.obtainToken({ code: req.query.code });
    • Get a new token pair using a refresh token. The refresh token is single use: store the returned refreshToken, the old one stops working.

      Parameters

      • options: { refreshToken: string }

      Returns Promise<OAuthTokens>

      const refreshed = await oauth.refreshToken({ refreshToken: stored.refreshToken });