infojobs-auth-library
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

InfoJobs API Authentication Library: Node.js Client

This is InfoJobs's unofficially supported node.js client library for using OAuth 2.0 authorization and authentication with InfoJobs API.

Quickstart

Installing the client library

npm install infojobs-auth-library

How to use

This library comes with OAuth2 class, you will use to generate URLs, get tokens, and refresh tokens.

A complete OAuth2 example

Let's take a look at a complete example.

const { OAuth2 } = require('infojobs-auth-library');

const auth = new OAuth2({
  clientId: process.env.CLIENT_ID,
  clientSecret: process.env.CLIENT_SECRET,
  redirectUri: process.env.REDIRECT_URI,
});

// Generate the url that will be used for the consent dialog.
const authUrl = auth.generateAuthUrl({
  responseType: 'code',
  scope: ['MY_APPLICATIONS'],
});

(async () => {
  const token = await auth.getAccessToken('2e386b32-af9a-4891-8caa-d1e3d7721f2');

  console.log(token);
  /**
   * {
   *  access_token: '2e386b32-af9a-4891-8caa-d1e3d7721f2',
   *  token_type: 'bearer',
   *  expires_in: 3599,
   *  refresh_token: '2e386b32-af9a-4891-8caa-d1e3d7721f2',
   */

  await auth.refreshAccessToken(token.refresh_token);
})();

Package Sidebar

Install

npm i infojobs-auth-library

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

26.9 kB

Total Files

7

Last publish

Collaborators

  • roberthgnz