ArchitectureAuthentication

OAuth2

OAuth2 authentication provides secure access to external services without sharing passwords. It uses access tokens that can be refreshed and provides fine-grained permissions.

Basic Usage

src/index.ts
import * as i from '@xentom/integration-framework';

export default i.integration({
  auth: i.auth.oauth2({
    authUrl: 'https://github.com/login/oauth/authorize',
    tokenUrl: 'https://github.com/login/oauth/access_token',
    scopes: ['admin:repo_hook', 'admin:org', 'repo'],
  }),

  nodes: {
    getUser: i.nodes.callable({
      inputs: {
        id: i.pins.data({
          control: i.controls.text({
            label: 'User ID',
          }),
        }),
      },
      outputs: {
        user: i.pins.data(),
      },
      async run({ auth, inputs, next }) {
        const response = await fetch(`https://api.example.com/users/${inputs.id}`, {
          headers: {
            Authorization: `Bearer ${auth.accessToken}`,
          },
        });

        return next({
          user: await response.json(),
        });
      },
    }),
  },
});

Configuration Options

Prop

Type

On this page