{"id":20215566,"url":"https://github.com/casdoor/casdoor-flutter-sdk","last_synced_at":"2025-10-08T07:43:53.653Z","repository":{"id":43645948,"uuid":"504999302","full_name":"casdoor/casdoor-flutter-sdk","owner":"casdoor","description":"Flutter SDK for Casdoor, see example at: https://github.com/casdoor/casdoor-flutter-example","archived":false,"fork":false,"pushed_at":"2025-06-10T06:44:35.000Z","size":4588,"stargazers_count":18,"open_issues_count":4,"forks_count":17,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-06-10T07:33:35.616Z","etag":null,"topics":["auth","authentication","authn","casdoor","dart","flutter","oauth","oidc","sdk","sso"],"latest_commit_sha":null,"homepage":"https://github.com/casdoor/casdoor","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/casdoor.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,"zenodo":null}},"created_at":"2022-06-19T03:03:26.000Z","updated_at":"2025-06-10T06:44:38.000Z","dependencies_parsed_at":"2024-01-29T00:03:25.842Z","dependency_job_id":"55e655a9-2dd8-44d2-bfe0-0dd585900121","html_url":"https://github.com/casdoor/casdoor-flutter-sdk","commit_stats":{"total_commits":36,"total_committers":9,"mean_commits":4.0,"dds":0.6666666666666667,"last_synced_commit":"90f7556d9e39724fab138b402da3ce4913d64c48"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/casdoor/casdoor-flutter-sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casdoor%2Fcasdoor-flutter-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casdoor%2Fcasdoor-flutter-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casdoor%2Fcasdoor-flutter-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casdoor%2Fcasdoor-flutter-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/casdoor","download_url":"https://codeload.github.com/casdoor/casdoor-flutter-sdk/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casdoor%2Fcasdoor-flutter-sdk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278909713,"owners_count":26066887,"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","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"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":["auth","authentication","authn","casdoor","dart","flutter","oauth","oidc","sdk","sso"],"created_at":"2024-11-14T06:23:21.534Z","updated_at":"2025-10-08T07:43:53.540Z","avatar_url":"https://github.com/casdoor.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Casdoor Flutter SDK\n\n\u003cp align=\"left\"\u003e\n    \u003ca href=\"https://pub.dev/packages/casdoor_flutter_sdk\"\u003e\u003cimg src=\"https://img.shields.io/pub/likes/casdoor_flutter_sdk?logo=flutter\" alt=\"Pub.dev likes\"/\u003e\u003c/a\u003e\n    \u003ca href=\"https://pub.dev/packages/casdoor_flutter_sdk\"\u003e\u003cimg src=\"https://img.shields.io/pub/points/casdoor_flutter_sdk?logo=flutter\" alt=\"Pub.dev points\"/\u003e\u003c/a\u003e\n    \u003ca href=\"https://pub.dev/packages/casdoor_flutter_sdk\"\u003e\u003cimg src=\"https://img.shields.io/pub/v/casdoor_flutter_sdk.svg?include_prereleases\" alt=\"latest version\"/\u003e\u003c/a\u003e\n    \u003ca href=\"https://pub.dev/packages/casdoor_flutter_sdk\"\u003e\u003cimg src=\"https://img.shields.io/badge/Platform-Android%20%7C%20iOS%20%7C%20macOS%20%7C%20Web-blue?logo=flutter\" alt=\"Platform\"/\u003e\u003c/a\u003e\n    \u003ca href=\"./LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/github/license/agoraio-community/flutter-uikit?color=lightgray\" alt=\"License\"/\u003e\u003c/a\u003e\n\u003c/p\u003e\n\ncasdoor-flutter-sdk will allow you to easily connect your Flutter-based application to the [Casdoor authentication system](https://casdoor.org/) without having to implement it from scratch.\n\nThe following platforms are supported:\n\n- Android\n- iOS\n- Linux\n- macOS\n- Web\n- Windows\n\n| **Android**                    | **iOS**                | **Web**                |\n| ------------------------------ | ---------------------- | ---------------------- |\n| ![Android](screen-andriod.gif) | ![iOS](screen-ios.gif) | ![Web](screen-web.gif) |\n\n# Features\n\nUse this plugin in your Flutter app to:\n\n- Connect to casdoor for SSO\n- Get the token after the casdoor authentication\n\n# Usage\n\nThis section has examples of code for the following tasks:\n\n- [Initialization requires 6 parameters](#jump1)\n- [Judgment platform](#jump2)\n- [Authorize with the Casdoor server](#jump3)\n- [Get token and parse](#jump4)\n\n\u003cspan id=\"jump1\"\u003eInitialization requires 6 parameters\u003c/span\u003e\n\nInitialization requires 6 parameters, which are all str type:\n| Name (in order) | Must | Description |\n| ---- | ---- |---- |\n| clientId | Yes | Application.client_id |\n| endpoint | Yes | Casdoor Server Url, such as `door.casdoor.com` |\n| organizationName | Yes | Organization name |\n| appName | Yes | Application name |\n| redirectUri | Yes | URI of Web redirection |\n| callbackUrlScheme | Yes | URL Scheme |\n\n```\n  final CasdoorFlutterSdkConfig _config =  CasdoorFlutterSdkConfig(\n      clientId: \"014ae4bd048734ca2dea\",\n      endpoint: \"door.casdoor.com\",\n      organizationName: \"casbin\",\n      appName: \"app-casnode\",\n      redirectUri: \"http://localhost:9000/callback\",\n      callbackUrlScheme: \"casdoor\"\n  );\n```\n\n\u003cspan id=\"jump2\"\u003eJudgment platform\u003c/span\u003e\n\nSet the callbackuri parameter by judging different platforms\n\n```\n final platform = await CasdoorFlutterSdkPlatform.getPlatformVersion();\n    String callbackUri;\n    if (platform == \"web\") {\n       callbackUri = \"${_config.redirectUri}.html\";\n    } else {\n       callbackUri = \"${_config.callbackUrlScheme}://callback\" ;\n    }\n```\n\n\u003cspan id=\"jump3\"\u003eAuthorize with the Casdoor server\u003c/span\u003e\n\nAt this point, we should use some ways to verify with the Casdoor server.\n\nTo start, we want you understand clearly the verification process of Casdoor. The following paragraphs will mention your app that wants to use Casdoor as a means of verification as `APP`, and Casdoor as `Casdoor`.\n\n1. `APP` will send a request to` Casdoor`.\n   Since `Casdoor` is a UI-based OAuth provider, you cannot use request management service like Postman to send a URL with parameters and get back a JSON file.\n\n2. The simplest way to try it out is to type the URL in your browser.\n\n3. Type in the URL in your browser in this format: `endpoint/login/oauth/authorize?client_id=xxx\u0026response_type=code\u0026redirect_uri=xxx\u0026scope=read\u0026state=xxx`\n   In this URL the `endpoint` is your Casdoor's location, as mentioned in Step1; then the `xxx` need to be filled out by yourself.\n\n\u003cspan id=\"jump4\"\u003eGet token and parse\u003c/span\u003e\n\nAfter Casdoor verification passed, it will be redirected to your application with code and state, like `https://localhost:9000/callback?code=xxx\u0026state=yyyy`.\n\nYour application can get the `code` and call` _casdoor.requestOauthAccessToken(code)`, then parse out jwt token.\n\n# Getting Started\n\nAdd casdoor-flutter-sdk to the dependencies of your pubspec.yaml.\n\n```\ndependencies:\n  casdoor_flutter_sdk: ^1.0.0\n```\n\nNotes for different platforms:\n\n## Android and iOS\n\nPlease check the [documentation](https://inappwebview.dev/docs/intro) of the InAppWebView package for more details about setting up the project.\n\n## Linux and macOS\n\nAdd the package `desktop_webview_window: ^0.2.3` inside *dependencies* to your *pubspec.yaml* file.\n\nModify your *main* function to look like the following:\n\n```\nvoid main(List\u003cString\u003e args) async {\n  WidgetsFlutterBinding.ensureInitialized();\n  if (runWebViewTitleBarWidget(args)) {\n    return;\n  }\n  // your code goes here ...\n  runApp(const MyApp());\n}\n```\n\nPlease check the [documentation](https://pub.dev/packages/desktop_webview_window) of the desktop_webview_window package for more details.\n\n## Web\n\nOn the Web platform an endpoint needs to be created that captures the callback URL and sends it to the application using the JavaScript postMessage() method. In the ./web folder of the project, create an HTML file with the name e.g. callback.html with content:\n\n```\n\u003c!DOCTYPE html\u003e\n\u003ctitle\u003eAuthentication complete\u003c/title\u003e\n\u003cp\u003eAuthentication is complete. If this does not happen automatically, please\nclose the window.\n\u003cscript\u003e\n  window.opener.postMessage({\n    'casdoor-auth': window.location.href\n  }, window.location.origin);\n  window.close();\n\u003c/script\u003e\n\n```\n\nRedirection URL passed to the authentication service must be the same as the URL on which the application is running (schema, host, port if necessary) and the path must point to created HTML file, /callback.html in this case, like `callbackUri = \"${_config.redirectUri}.html\"`. The callbackUrlScheme parameter of the authenticate() method does not take into account, so it is possible to use a schema for native platforms in the code.It should be noted that when obtaining a token, cross domain may occur\n\nFor the Sign in with Apple in web_message response mode, postMessage from https://appleid.apple.com is also captured, and the authorization object is returned as a URL fragment encoded as a query string (for compatibility with other providers).\n\n# API reference interface\n\n#### Get sign up url\n\n```typescript\ngetSignupUrl(enablePassword)\n```\n\n#### Get sign in url\n\n```typescript\ngetSigninUrl()\n```\n\n#### Get code in a new window (all platforms)\n\n```typescript\nshow()\n```\n\n#### Get code inside the app (Android and iOS)\n\n```typescript\nshowFullscreen()\n```\n\n#### Get token\n\n```typescript\nrequestOauthAccessToken()\n```\n\n#### Refresh token\n\n```typescript\nrefreshToken()\n```\n\n#### Log out\n\n```typescript\ntokenLogout()\n```\n\n#### Get user information\n\n```typescript\ngetUserInfo()\n```\n\n#### Decode token\n\n```typescript\ndecodedToken()\n```\n\n#### Judge whether the token is expired\n\n```typescript\nisTokenExpired()\n```\n\n#### Verify nonce\n\n```typescript\nisNonce()\n```\n\n# Caveats\n\n## Windows\n\nThere is a known bug in the desktop_webview_window package that causes random crashes of the browser window (see [issue](https://github.com/MixinNetwork/flutter-plugins/issues/283)).\n\n## Linux (Ubuntu)\n\nDo not install Flutter or Visual Studio Code using Snap as this will prevent the code from building or running successfully. You need to install the Flutter and Visual Studio Code packages manually.\n\n## macOS\n\nThere are instances where JavaScript is not working inside WKWebView. Please report any bugs that may occur.\n\n# Example\n\nSee at: https://github.com/casdoor/casdoor-flutter-example\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcasdoor%2Fcasdoor-flutter-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcasdoor%2Fcasdoor-flutter-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcasdoor%2Fcasdoor-flutter-sdk/lists"}