1.1.1 • Published 2 years ago

@formance/formance-sdk-oauth v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

@formance/formance-sdk-oauth

This package provides a simple way to authenticate with the Formance API.

Installation

npm install @formance/formance-sdk-oauth

Usage

import { SDK as Formance } from '@formance/formance-sdk';
import { createAuthorizationProvider } from '@formance/formance-sdk-oauth';

const ENDPOINT = "https://xxxxxxxxxx-xxxx.sandbox.formance.cloud";

const formance = new Formance({
    serverURL: ENDPOINT,
    authorization: createAuthorizationProvider({
        endpointUrl: ENDPOINT,
        // These are sensitive credentials that should not be exposed to the public.
        clientId: "<OAuth client id>",
        clientSecret: "<OAuth client id>",
    }),
});

async function main() {
    const ledgerInfo = await formance.ledger.getInfo();
    console.log(ledgerInfo.configInfoResponse!.data);
}

main();

API Reference

createAuthorizationProvider

Return a function that can be used to return an authorization header for authenticating with the Formance API. Internally, it uses the OAuth 2.0 Client Credentials Grant with no scope to obtain an access token.

Parameters

NameTypeDescription
optionsOAuthOptionsOptions for the OAuth provider.

OAuthOptions reference

NameTypeDescription
endpointUrlstringThe URL of the Formance API for your stack.
clientIdstringThe OAuth client id.
clientSecretstringThe OAuth client secret.
tolerance?numberThe number of milliseconds to allow for clock skew. Defaults to 5 minutes.

Returns

A function that can be used to return an authorization header for authenticating with the Formance API.

1.1.1

2 years ago

1.1.0

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago