Coder Social home page Coder Social logo

formance-sdk-typescript-oauth's Introduction

@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

Name Type Description
options OAuthOptions Options for the OAuth provider.

OAuthOptions reference

Name Type Description
endpointUrl string The URL of the Formance API for your stack.
clientId string The OAuth client id.
clientSecret string The OAuth client secret.
tolerance? number The 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.

formance-sdk-typescript-oauth's People

Watchers

Antoine Wacheux avatar laouji avatar Alexandre Gourdel avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.