@bolomio/cognito-authorizer
v1.0.0
Published
functions to authorize to amazon cognito
Downloads
298
Readme
[bolomio] Cognito Authorizer
The @bolomio/cognito-authorizer package is an open-source lightweight npm package that provides functions for authenticating with cognito using different authentication flows. It allows you to easily authenticate cognito instances in your Node.js applications.
Features
- Authenticate with cognito using the client credential flow
Installation
You can install the package using npm:
npm install @bolomio/cognito-authorizer
Usage
const { makeCognitoAuthorizer } = require('@bolomio/cognito-authorizer');
const { HTTPError } = require('got');
// Create an instance of the cognito authorizer with custom options
const authorizer = makeCognitoAuthorizer({
baseUrl: "https://{domain-name}.auth.{region}.amazoncognito.com/",
});
async function authenticate() {
try {
const resource = await authorizer.authenticateWithClientCredentials({
clientId: 'YOUR_CLIENT_ID',
clientSecret: 'YOUR_CLIENT_SECRET',
});
console.log(resource);
} catch (e) {
if (e instanceof HTTPError) {
console.log(e.response.body);
}
}
}
authenticate();
Contributing
Contributions are welcome! If you encounter any issues or have suggestions for improvements, please feel free to open an issue or submit a pull request. Make sure to follow the contribution guidelines.
License
This project is licensed under the GNU General Public License.