{"id":16000641,"url":"https://github.com/twirelab/nestjs-auth0","last_synced_at":"2025-03-17T16:30:22.711Z","repository":{"id":40369477,"uuid":"491026763","full_name":"Twirelab/nestjs-auth0","owner":"Twirelab","description":"Auth0 wrapper for Nestjs","archived":false,"fork":false,"pushed_at":"2025-02-26T06:14:38.000Z","size":153,"stargazers_count":5,"open_issues_count":2,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-16T12:42:23.259Z","etag":null,"topics":["auth0","auth0-jwt","authentication","express","management","nextjs","nodejs","plugins"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Twirelab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-11T08:41:33.000Z","updated_at":"2025-02-21T15:02:13.000Z","dependencies_parsed_at":"2023-12-29T15:25:13.129Z","dependency_job_id":"0f15e86b-fadb-48e4-9b96-e8bb4c677b25","html_url":"https://github.com/Twirelab/nestjs-auth0","commit_stats":{"total_commits":13,"total_committers":4,"mean_commits":3.25,"dds":0.6153846153846154,"last_synced_commit":"822aef77f324bd5a10ec125ddb6b959c38c84b0f"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Twirelab%2Fnestjs-auth0","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Twirelab%2Fnestjs-auth0/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Twirelab%2Fnestjs-auth0/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Twirelab%2Fnestjs-auth0/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Twirelab","download_url":"https://codeload.github.com/Twirelab/nestjs-auth0/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244068706,"owners_count":20392878,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["auth0","auth0-jwt","authentication","express","management","nextjs","nodejs","plugins"],"created_at":"2024-10-08T09:05:19.572Z","updated_at":"2025-03-17T16:30:22.136Z","avatar_url":"https://github.com/Twirelab.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NestJS Auth0\n\n[![Test package](https://github.com/Twirelab/nestjs-auth0/actions/workflows/tests.yml/badge.svg)](https://github.com/Twirelab/nestjs-auth0/actions/workflows/tests.yml)\n\nNodeJS Auth0 wrapper for Nestjs\n\n## Install\n```bash\nnpm i @twirelab/nestjs-auth0 auth0\nnpm i -D @types/auth0\n```\n\nor\n\n```bash\nyarn add @twirelab/nestjs-auth0 auth0\nyarn add -D @types/auth0\n```\n\n## Authentication Client\n\nAdd below code into app.module.js file.\n```typescript\nimport { AuthenticationModule } from \"@twirelab/nestjs-auth0\";\n\n@Module({\n  imports: [\n    AuthenticationModule.forRoot({\n      domain: '{YOUR_ACCOUNT}.auth0.com',\n      clientId: '{CLIENT_ID}',\n      clientSecret: '{CLIENT_SECRET}',\n    }),\n  ],\n})\nexport class AppModule {}\n```\n\nNow you can inject authentication client into your services, for example:\n```typescript\nimport { Injectable } from '@nestjs/common';\nimport { InjectAuthentication } from \"@twirelab/nestjs-auth0\";\nimport { AuthenticationClient, TokenResponse } from \"auth0\";\n\n@Injectable()\nexport class AppService {\n  constructor(@InjectAuthentication() private readonly authentication: AuthenticationClient) { }\n\n  async getCredentialsGrant(): Promise\u003cTokenResponse\u003e {\n    return await this.authentication.clientCredentialsGrant({ audience: \"...\" });\n  }\n}\n```\n\n## Management Client\n\nAdd below code into app.module.js file.\n```typescript\nimport { ManagementModule } from \"@twirelab/nestjs-auth0\";\n\n@Module({\n  imports: [\n    ManagementModule.forRoot({\n      token: '{YOUR_API_V2_TOKEN}',\n      domain: '{YOUR_ACCOUNT}.auth0.com',\n    }),\n  ],\n})\nexport class AppModule {}\n```\n\nNow you can inject management client into your services, for example:\n```typescript\nimport { Injectable } from \"@nestjs/common\";\nimport { InjectManagement } from \"@twirelab/nestjs-auth0\";\nimport { ManagementClient, User } from \"auth0\";\n\n@Injectable()\nexport class AppService {\n  constructor(@InjectManagement() private readonly management: ManagementClient) { }\n\n  async getUsers(): Promise\u003cUser[]\u003e {\n    return await this.management.getUsers();\n  }\n}\n```\n\nTo obtain **automatically** a Management API token via the ManagementClient, you can specify the parameters `clientId`, `clientSecret` (use a Non Interactive Client) and optionally `scope`. Behind the scenes the Client Credentials Grant is used to obtain the `access_token` and is by default cached for the duration of the returned `expires_in` value.\n\n```typescript\nimport { ManagementModule } from \"@twirelab/nestjs-auth0\";\n\n@Module({\n  imports: [\n    ManagementModule.forRoot({\n      domain: '{YOUR_ACCOUNT}.auth0.com',\n      clientId: '{YOUR_NON_INTERACTIVE_CLIENT_ID}',\n      clientSecret: '{YOUR_NON_INTERACTIVE_CLIENT_SECRET}',\n      scope: 'read:users update:users',\n    }),\n  ],\n})\nexport class AppModule {}\n```\n\nMore details you can find here: [auth0/node-auth0](https://github.com/auth0/node-auth0/blob/master/README.md)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftwirelab%2Fnestjs-auth0","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftwirelab%2Fnestjs-auth0","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftwirelab%2Fnestjs-auth0/lists"}