Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@salling-group/auth

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@salling-group/auth

Makes it easy to authenticate when using Salling Group's APIs.

  • 1.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-62.5%
Maintainers
1
Weekly downloads
 
Created
Source

Salling Group API Authentication

Build Status

This library allows you to easily set up an Axios instance that can query the Salling Group API.

Getting Started

This will check if 2017-12-24 is a holiday by querying the Holidays API.

const { createInstance } = require('@salling-group/auth');
const instance = createInstance({
  'applicationName': 'My Application v1.0.1',
  'auth': {
    'type': 'bearer',
    'token': 'my_token',
  },
});

instance.get('/v1/holidays/is-holiday', {
  'params': {
    'date': '2017-12-24',
  },
}).then((response) => console.log(response.data));

Instance

The authentication library exposes two authentication methods for setting up an Axios instance. This means that you can use this instance as you would use Axios, and it will handle authentication for you.

The available authentication methods are Bearer and JWT. You can get your credentials on the developer portal.

getInstance(options: object): Instance

This function gets a new Axios instance with access to the Salling Group API (given the provided credentials are correct and has access to the requested ressource). The provided options object must contain an auth object with the following specification:

PropertyValueRequiredDescription
type'jwt' or 'bearer'YesThe authentication type. This is either a JWT or a Bearer Token.
tokenStringIf type is 'bearer'.The token associared with the bearer token credentials.
issuerStringIf type is 'jwt'.The issuer associated with the JWT credentials.
secretStringIf type is 'jwt'.The secret associated with the JWT credentials.

Examples

Bearer

If you use a Bearer token, you can access the API like this:

const instance = createInstance({
  'applicationName': 'My Application v1.0.1',
  'auth': {
    'type': 'bearer',
    'token': 'my_token',
  },
});
instance.get('/v1/stores/').then(response => {
  console.log(response.data);
});

JWT

If you use a JWT, you can access the API like so:

const instance = createInstance({
  'applicationName': 'My Application v1.0.1',
  'auth': {
    'type': 'jwt',
    'issuer': 'my_issuer',
    'secret': 'my_secret',
  },
});
instance.get('/v1/stores/').then(response => {
  console.log(response.data);
});

FAQs

Package last updated on 03 Jul 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc