Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/roberthgnz/infojobs-auth-library
InfoJobs API Authentication Client Library for Node.js
https://github.com/roberthgnz/infojobs-auth-library
infojobs infojobs-api project
Last synced: 9 days ago
JSON representation
InfoJobs API Authentication Client Library for Node.js
- Host: GitHub
- URL: https://github.com/roberthgnz/infojobs-auth-library
- Owner: roberthgnz
- Created: 2023-05-17T15:39:59.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-05-19T16:37:51.000Z (over 1 year ago)
- Last Synced: 2025-01-16T20:39:14.185Z (13 days ago)
- Topics: infojobs, infojobs-api, project
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/infojobs-auth-library
- Size: 55.7 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# InfoJobs API Authentication Library: Node.js Client
This is InfoJobs's unofficially supported [node.js](http://nodejs.org/) client library for using OAuth 2.0 authorization and authentication with InfoJobs API.
- [Quickstart](#quickstart)
- [Installing the client library](#installing-the-client-library)
- [How to use](#how-to-use)
- [A complete OAuth2 example](#a-complete-oauth2-example)
## Quickstart
### Installing the client library
```bash
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.
```javascript
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 () => {
// IMPORTANT
// You need the verification code generated with the dialog url
const token = await auth.getAccessToken(code);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);
})();
```