{"id":19422849,"url":"https://github.com/dutchcodingcompany/oauth_chopper","last_synced_at":"2025-04-24T15:32:27.098Z","repository":{"id":59310572,"uuid":"536565757","full_name":"DutchCodingCompany/oauth_chopper","owner":"DutchCodingCompany","description":"Add and manage OAuth2 authentication for your Chopper client.","archived":false,"fork":false,"pushed_at":"2025-02-11T10:59:43.000Z","size":116,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-20T10:26:06.205Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Dart","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/DutchCodingCompany.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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-09-14T12:23:40.000Z","updated_at":"2025-02-11T10:58:22.000Z","dependencies_parsed_at":"2024-03-14T16:48:08.628Z","dependency_job_id":"12686ff0-024e-45ed-a8ee-d5dc2397610c","html_url":"https://github.com/DutchCodingCompany/oauth_chopper","commit_stats":{"total_commits":5,"total_committers":1,"mean_commits":5.0,"dds":0.0,"last_synced_commit":"aa13e42d2ba32346f1e643543c81bf52bc7c40d6"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DutchCodingCompany%2Foauth_chopper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DutchCodingCompany%2Foauth_chopper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DutchCodingCompany%2Foauth_chopper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DutchCodingCompany%2Foauth_chopper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DutchCodingCompany","download_url":"https://codeload.github.com/DutchCodingCompany/oauth_chopper/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250654496,"owners_count":21465893,"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":[],"created_at":"2024-11-10T13:35:30.422Z","updated_at":"2025-04-24T15:32:26.832Z","avatar_url":"https://github.com/DutchCodingCompany.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!--     \nThis README describes the package. If you publish this package to pub.dev,    \nthis README's contents appear on the landing page for your package.    \n    \nFor information about how to write a good package README, see the guide for    \n[writing package pages](https://dart.dev/guides/libraries/writing-package-pages).     \n    \nFor general information about developing packages, see the Dart guide for    \n[creating packages](https://dart.dev/guides/libraries/create-library-packages)    \nand the Flutter guide for    \n[developing packages and plugins](https://flutter.dev/developing-packages).     \n--\u003e    \n\nAdd and manage OAuth2 authentication for your Chopper client\n\n## Features\n\nOffers a `oauth_chopper` client to help manage your OAuth2 authentication\nwith [Choppper](https://pub.dev/packages/chopper). The `oauth_chopper` client\nuses [oauth2](https://pub.dev/packages/oauth2) package from the dart team and combines this with\nChopper. It offers a Chopper Authenticator and HeaderInterceptor to manage the OAuth2\nauthorizations.\n\nBy default it doesn't persist any credential information. It uses an in memory storage by default.\nThis can be override by providing a custom storage implementation.\n\n**Currently it supports the following grants:**\n\n- ✅ ResourceOwnerPasswordGrant\n- ✅ ClientCredentialsGrant\n- ✅ AuthorizationCodeGrant\n\n## Usage\n\nCreate a `oauth_chopper` client with the needed authorizationEndpoint, identifier and secret.  \nAdd the `oauth_chopper_interceptor` to your chopper client.  \nRequest a OAuthGrant on the `oauth_chopper` client.\n\nExample:\n\n```dart    \n  /// Create OAuthChopper instance.\n  final oauthChopper = OAuthChopper(\n    authorizationEndpoint: authorizationEndpoint,\n    identifier: identifier,\n    secret: secret,\n  );\n\n  /// Add the oauth authenticator and interceptor to the chopper client.\n  final chopperClient = ChopperClient(\n    baseUrl: Uri.parse('https://example.com'),\n    interceptors: [\n      oauthChopper.interceptor(),\n    ],\n  );\n\n  /// Request grant\n  oauthChopper.requestGrant(\n    ResourceOwnerPasswordGrant(\n      username: 'username',\n      password: 'password',\n    ),\n  );\n\n// Authorization Cod eGrant\n  oauth_chopper.AuthorizationCodeGrant grant = oauth_chopper.AuthorizationCodeGrant(\n    tokenEndpoint: Uri.parse(\"tokenEndpoint\"),\n    scopes: [\"scope1\", \"scope2\"],\n    redirectUrl: Uri.parse(\"redirectUrl\"),\n    redirect: redirect,\n    listen: listen,\n  );\n```   \n\nIf you want to persist the OAuth2 credential information you can provide a custom OAuthStorage\nimplementation for example\nwith [flutter_secure_storage](https://pub.dev/packages/flutter_secure_storage):\n\n```dart  \nconst _storageKey = 'storage_key';  \n  \nclass OAuthCredentialsStorage implements OAuthStorage {    \n  final FlutterSecureStorage _storage;    \n    \n const OAuthCredentialsStorage(this._storage);    \n    \n  @override    \n  FutureOr\u003cvoid\u003e clear() async {    \n    await _storage.delete(key: _storageKey);    \n  }    \n    \n  @override    \n  FutureOr\u003cString?\u003e fetchCredentials() async {    \n    final credentialsJson = await _storage.read(key: _storageKey);    \n return credentialsJson;    \n  }    \n    \n  @override    \n  FutureOr\u003cvoid\u003e saveCredentials(String? credentialsJson) async {    \n    await _storage.write(key: _storageKey, value: credentialsJson);    \n} }  \n```  \n\n## Additional information\n\n- [OAuth2](https://oauth.net/2/)\n- [OAuth2 package](https://pub.dev/packages/oauth2)\n- [Chopper package](https://pub.dev/packages/chopper)\n\nFeel free to give me any feedback to improve this package.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdutchcodingcompany%2Foauth_chopper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdutchcodingcompany%2Foauth_chopper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdutchcodingcompany%2Foauth_chopper/lists"}