{"id":36545129,"url":"https://github.com/aidant/lazy-oauth2-implicit-grant-client","last_synced_at":"2026-01-12T05:59:44.917Z","repository":{"id":57126439,"uuid":"404698998","full_name":"aidant/lazy-oauth2-implicit-grant-client","owner":"aidant","description":"A simple OAuth 2.0 Implicit Grant client for the lazy developer.","archived":false,"fork":false,"pushed_at":"2022-04-18T05:23:47.000Z","size":12,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-28T00:37:46.183Z","etag":null,"topics":["authentication","grant","implicit","oauth","oauth2"],"latest_commit_sha":null,"homepage":"https://github.com/aidant/lazy-oauth2-implicit-grant-client","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aidant.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-09-09T11:39:52.000Z","updated_at":"2022-06-10T11:42:56.000Z","dependencies_parsed_at":"2022-08-24T14:59:37.012Z","dependency_job_id":null,"html_url":"https://github.com/aidant/lazy-oauth2-implicit-grant-client","commit_stats":null,"previous_names":["aidant/implicit-grant"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/aidant/lazy-oauth2-implicit-grant-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aidant%2Flazy-oauth2-implicit-grant-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aidant%2Flazy-oauth2-implicit-grant-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aidant%2Flazy-oauth2-implicit-grant-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aidant%2Flazy-oauth2-implicit-grant-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aidant","download_url":"https://codeload.github.com/aidant/lazy-oauth2-implicit-grant-client/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aidant%2Flazy-oauth2-implicit-grant-client/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28336039,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T00:36:25.062Z","status":"online","status_checked_at":"2026-01-12T02:00:08.677Z","response_time":98,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["authentication","grant","implicit","oauth","oauth2"],"created_at":"2026-01-12T05:59:40.832Z","updated_at":"2026-01-12T05:59:44.912Z","avatar_url":"https://github.com/aidant.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lazy OAuth 2.0 Implicit Grant Client\n\n\u003cp align='center'\u003e\n  A simple OAuth 2.0 Implicit Grant client for the lazy developer.\n  \u003cbr\u003e\n  \u003ca href='https://www.npmjs.com/package/@lazy/oauth2-implicit-grant-client'\u003e\n    \u003cimg src=\"https://img.shields.io/npm/v/@lazy/oauth2-implicit-grant-client?style=flat-square\"\u003e\n  \u003c/a\u003e\n  \u003ca href='https://bundlephobia.com/package/@lazy/oauth2-implicit-grant-client'\u003e\n    \u003cimg src=\"https://img.shields.io/bundlephobia/minzip/@lazy/oauth2-implicit-grant-client?label=minified%20%26%20gzipped\u0026style=flat-square\"\u003e\n  \u003c/a\u003e\n  \u003ca href='https://github.com/aidant/lazy-oauth2-implicit-grant-client/actions/workflows/publish.yml'\u003e\n    \u003cimg src=\"https://img.shields.io/github/workflow/status/aidant/lazy-oauth2-implicit-grant-client/Publish?style=flat-square\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n---\n\n## Table of Contents\n\n- [Example](#example)\n- [API](#api)\n  - [`handleImplicitGrantFlow`]\n  - [`handleImplicitGrantCallback`]\n  - [`createImplicitGrantURL`]\n  - [`getImplicitGrantResponse`]\n\n## Example\n\n```ts\nimport {\n  handleImplicitGrantFlow,\n  handleImplicitGrantCallback,\n} from '@lazy/oauth2-implicit-grant-client'\n\nhandleImplicitGrantCallback()\n\nconst button = document.createElement('button')\nbutton.textContent = 'Login'\n\nbutton.addEventListener('click', () =\u003e {\n  const response = await handleImplicitGrantFlow('https://api.example.com/authorize', {\n    client_id: 'example-client-id',\n  })\n  const token = `${response.token_type} ${response.access_token}`\n  console.log(token)\n})\n```\n\n## API\n\n### `handleImplicitGrantFlow`\n\nThe [`handleImplicitGrantFlow`] function handles the Implicit Grant\nauthentication flow. A new window is created where the user is then prompted to\nauthenticate with the OAuth 2.0 provider, once the user had accepted or rejected\nthe request the `handleImplicitGrantCallback` function then handles the response\nand returns it back via the promise from `handleImplicitGrantFlow` - just like\nmagic.\n\n#### Parameters\n\n- `endpoint` - **string** - The Authorization endpoint of the OAuth 2.0 provider.\n- `parameters` - _object_ - The OAuth 2.0 parameters such as; `client_id`, `scope`, and/or `redirect_uri`.\n\n#### Example\n\n```ts\nimport { handleImplicitGrantFlow } from '@lazy/oauth2-implicit-grant-client'\n\nconst button = document.createElement('button')\nbutton.textContent = 'Login'\n\nbutton.addEventListener('click', () =\u003e {\n  const response = await handleImplicitGrantFlow('https://api.example.com/authorize', {\n    client_id: 'example-client-id',\n  })\n  const token = `${response.token_type} ${response.access_token}`\n  console.log(token)\n})\n```\n\nReturns `Promise\u003cImplicitGrantSuccessResponse\u003e`\n\n### `handleImplicitGrantCallback`\n\nThe [`handleImplicitGrantCallback`] function is responsible for returning the\nresponse from the authentication endpoint back to the\n[`handleImplicitGrantFlow`] function. If you call the\n[`handleImplicitGrantFlow`] and [`handleImplicitGrantCallback`] functions in the\nsame page make sure you call the [`handleImplicitGrantCallback`] function before\nthe [`handleImplicitGrantFlow`].\n\n#### Example\n\n```ts\nimport { handleImplicitGrantCallback } from '@lazy/oauth2-implicit-grant-client'\n\nhandleImplicitGrantCallback()\n```\n\nReturns `void`\n\n### `createImplicitGrantURL`\n\nThe [`createImplicitGrantURL`] function allows you to create a URL that can be\nused in the dom on anchor tags or the like to improve accessability over buttons\nwith click handlers.\n\nThis URL should only be used once, if you need you can call\n[`createImplicitGrantURL`] multiple times to get several url's.\n\n#### Parameters\n\n- `endpoint` - **string** - The Authorization endpoint of the OAuth 2.0 provider.\n- `parameters` - _object_ - The OAuth 2.0 parameters such as; `client_id`, `scope`, and/or `redirect_uri`.\n\n#### Example\n\n```ts\nimport { createImplicitGrantURL } from '@lazy/oauth2-implicit-grant-client'\n\nconst url = createImplicitGrantURL('https://api.example.com/authorize', {\n  client_id: 'example-client-id',\n})\n\nconst a = document.createElement('a')\na.href = url.href\na.target = '_blank'\na.rel = 'noopener'\na.textContent = 'Login'\n\na.addEventListener(\n  'click',\n  () =\u003e {\n    a.remove()\n  },\n  { once: true }\n)\n\ndocument.append(a)\n```\n\nReturns `URL`\n\n### `getImplicitGrantResponse`\n\n#### Parameters\n\n- `url` - **URL** - The URL that started the OAuth 2.0 Flow.\n\n#### Example\n\n```ts\nimport {\n  createImplicitGrantURL,\n  getImplicitGrantResponse,\n} from '@lazy/oauth2-implicit-grant-client'\n\nconst url = createImplicitGrantURL('https://api.example.com/authorize', {\n  client_id: 'example-client-id',\n})\n\nconst a = document.createElement('a')\na.href = url.href\na.target = '_blank'\na.rel = 'noopener'\na.textContent = 'Login'\n\na.addEventListener(\n  'click',\n  async () =\u003e {\n    a.remove()\n    const response = await getImplicitGrantResponse(url)\n    const token = `${response.token_type} ${response.access_token}`\n    console.log(token)\n  },\n  { once: true }\n)\n\ndocument.append(a)\n```\n\nReturns `Promise\u003cImplicitGrantSuccessResponse\u003e`\n\n[`handleimplicitgrantflow`]: #handleimplicitgrantflow\n[`handleimplicitgrantcallback`]: #handleimplicitgrantcallback\n[`createimplicitgranturl`]: #createimplicitgranturl\n[`getimplicitgrantresponse`]: #getimplicitgrantresponse\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faidant%2Flazy-oauth2-implicit-grant-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faidant%2Flazy-oauth2-implicit-grant-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faidant%2Flazy-oauth2-implicit-grant-client/lists"}