{"id":29195866,"url":"https://github.com/casdoor-net/casdoor-dotnet-maui-example","last_synced_at":"2026-04-30T03:32:24.502Z","repository":{"id":301185494,"uuid":"1008440003","full_name":"casdoor-net/casdoor-dotnet-maui-example","owner":"casdoor-net","description":".NET MAUI app and .NET MAUI library example for Casdoor","archived":false,"fork":false,"pushed_at":"2025-06-25T14:53:32.000Z","size":1381,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-25T15:52:09.847Z","etag":null,"topics":["auth","authentication","authn","cas","casbin","casdoor","csharp","dotnet","example","identity","maui","oauth","oauth2","oidc","saml","sdk"],"latest_commit_sha":null,"homepage":"https://github.com/casdoor/casdoor-dotnet-sdk","language":"C#","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-net.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,"zenodo":null}},"created_at":"2025-06-25T14:45:51.000Z","updated_at":"2025-06-25T14:56:45.000Z","dependencies_parsed_at":"2025-06-25T15:52:14.877Z","dependency_job_id":"01d0ebd8-68dd-4acd-bd18-6d8b408e3f36","html_url":"https://github.com/casdoor-net/casdoor-dotnet-maui-example","commit_stats":null,"previous_names":["casdoor-net/casdoor-dotnet-maui-example"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/casdoor-net/casdoor-dotnet-maui-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casdoor-net%2Fcasdoor-dotnet-maui-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casdoor-net%2Fcasdoor-dotnet-maui-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casdoor-net%2Fcasdoor-dotnet-maui-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casdoor-net%2Fcasdoor-dotnet-maui-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/casdoor-net","download_url":"https://codeload.github.com/casdoor-net/casdoor-dotnet-maui-example/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casdoor-net%2Fcasdoor-dotnet-maui-example/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263077629,"owners_count":23410167,"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":["auth","authentication","authn","cas","casbin","casdoor","csharp","dotnet","example","identity","maui","oauth","oauth2","oidc","saml","sdk"],"created_at":"2025-07-02T05:06:31.805Z","updated_at":"2026-04-30T03:32:14.491Z","avatar_url":"https://github.com/casdoor-net.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# casdoor-dotnet-maui-example\nThe repository contain .NET MAUI app and .NET MAUI library for demonstration [Casdoor](https://casdoor.org/) authentication by Open ID Connect.\n\n## Demonstration\n\n### **Android**\n\n\u003cimg src=\"images/android.gif\" widht=200  height=600/\u003e\n\n### **Windows**\n\n\u003cimg src=\"images/windows.gif\" widht=600  height=300/\u003e\n\n# Requirements\n\n- [.NET 7 SDK](https://dotnet.microsoft.com/download/dotnet/7.0) installed on your machine\n- The required assets needed for your target(s) platform(s) as described [here](https://docs.microsoft.com/en-us/dotnet/maui/get-started/first-app)\n- Visual Studio 2022 for Windows 17.3  or Visual Studio 2022 for Mac 17.4 (optional)\n\n## Getting started\n\n### Step 1: Create MAUI Application\n\nCreate your [MAUI Application](https://docs.microsoft.com/en-us/dotnet/maui/get-started/first-app).\n\n### Step 2: Add reference\n\nAdd a reference to the `Casdoor.MauiOidcClient` in your project.  \n\n### Step 3: Add Casdoor client\n\nAdd `CasdoorClient` as singleton in the services.\n\n```csharp\nbuilder.Services.AddSingleton(new CasdoorClient(new()\n{\n    Domain = \"exlens.ru\",\n    ClientId = \"660682724e779be2a6f2\",\n    Scope = \"openid profile email\",\n\n#if WINDOWS\n    RedirectUri = \"http://localhost/callback\"\n#else\n    RedirectUri = \"casdoor://callback\"\n#endif\n}));\n```\n\n### Step 4: Design UI\n\nAdd code to `MainPage` file.\n\n**MainPage.xaml**\n```xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\" ?\u003e\n\u003cContentPage xmlns=\"http://schemas.microsoft.com/dotnet/2021/maui\"\n             xmlns:x=\"http://schemas.microsoft.com/winfx/2009/xaml\"\n             x:Class=\"Casdoor.MauiOidcClient.Example.MainPage\"\u003e\n\n    \u003cScrollView\u003e\n        \u003cVerticalStackLayout\u003e\n\n            \u003cStackLayout\n                x:Name=\"LoginView\"\u003e\n                \u003cButton \n                    x:Name=\"LoginBtn\"\n                    Text=\"Log In\"\n                    SemanticProperties.Hint=\"Click to log in\"\n                    Clicked=\"OnLoginClicked\"\n                    HorizontalOptions=\"Center\" /\u003e\n\n                \u003cWebView x:Name=\"WebViewInstance\" /\u003e\n            \u003c/StackLayout\u003e\n\n            \u003cStackLayout\n                x:Name=\"HomeView\"\n                IsVisible=\"false\"\u003e             \n\n                \u003cLabel\n                Text=\"Welcome to .NET Multi-platform App UI\"\n                SemanticProperties.HeadingLevel=\"Level2\"\n                SemanticProperties.Description=\"Welcome to dot net Multi platform App U I\"\n                FontSize=\"18\"\n                HorizontalOptions=\"Center\" /\u003e\n\n                \u003cButton\n                x:Name=\"CounterBtn\"\n                Text=\"Click me\"\n                SemanticProperties.Hint=\"Counts the number of times you click\"\n                Clicked=\"OnCounterClicked\"\n                HorizontalOptions=\"Center\" /\u003e\n\n                \u003cLabel \n                x:Name=\"NameLabel\"\n                Text=\"\"\n                SemanticProperties.HeadingLevel=\"Level2\"\n                SemanticProperties.Description=\"User's name\"\n                FontSize=\"18\"\n                HorizontalOptions=\"Center\" /\u003e\n\n                \u003cLabel \n                x:Name=\"EmailLabel\"\n                Text=\"\"\n                SemanticProperties.HeadingLevel=\"Level2\"\n                SemanticProperties.Description=\"User's email\"\n                FontSize=\"18\"\n                HorizontalOptions=\"Center\" /\u003e           \n\n                \u003cButton \n                x:Name=\"LogoutBtn\"\n                Text=\"Log Out\"\n                SemanticProperties.Hint=\"Click to log out\"\n                Clicked=\"OnLogoutClicked\"\n                HorizontalOptions=\"Center\" /\u003e\n\n            \u003c/StackLayout\u003e\n        \u003c/VerticalStackLayout\u003e\n    \u003c/ScrollView\u003e\n\n\u003c/ContentPage\u003e\n```\n\n**MainPage.cs**\n```csharp\nnamespace Casdoor.MauiOidcClient.Example\n{\n    public partial class MainPage : ContentPage\n    {\n        int count = 0;\n        private readonly CasdoorClient client;\n        private string acsessToken;\n        public MainPage(CasdoorClient client)\n        {\n            InitializeComponent();\n            this.client = client;\n\n#if WINDOWS\n    client.Browser = new WebViewBrowserAuthenticator(WebViewInstance);\n#endif\n        }\n\n        private void OnCounterClicked(object sender, EventArgs e)\n        {\n            count++;\n\n            if (count == 1)\n                CounterBtn.Text = $\"Clicked {count} time\";\n            else\n                CounterBtn.Text = $\"Clicked {count} times\";\n\n            SemanticScreenReader.Announce(CounterBtn.Text);\n        }\n\n        private async void OnLoginClicked(object sender, EventArgs e)\n        {\n            var loginResult = await client.LoginAsync();\n            acsessToken = loginResult.AccessToken;\n            if (!loginResult.IsError)\n            {\n                NameLabel.Text = loginResult.User.Identity.Name;\n                EmailLabel.Text = loginResult.User.Claims.FirstOrDefault(c =\u003e c.Type == \"email\")?.Value;            \n\n                LoginView.IsVisible = false;\n                HomeView.IsVisible = true;\n            }\n            else\n            {\n                await DisplayAlert(\"Error\", loginResult.ErrorDescription, \"OK\");\n            }\n        }\n\n        private async void OnLogoutClicked(object sender, EventArgs e)\n        {\n            var logoutResult = await client.LogoutAsync(acsessToken);\n\n\n            if (!logoutResult.IsError)\n            {\n                HomeView.IsVisible = false;\n                LoginView.IsVisible = true;\n                this.Focus();\n            }\n            else\n            {\n                await DisplayAlert(\"Error\", logoutResult.ErrorDescription, \"OK\");\n            }\n        }\n    }\n}\n```\n\n\n### Step 5: Support Android platform\n\nModify `AndroidManifest.xml` file.\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003cmanifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\u003e\n\t\u003capplication android:allowBackup=\"true\" android:icon=\"@mipmap/appicon\" android:roundIcon=\"@mipmap/appicon_round\" android:supportsRtl=\"true\"\u003e\u003c/application\u003e\n\t\u003cuses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\" /\u003e\n\t\u003cuses-permission android:name=\"android.permission.INTERNET\" /\u003e\n\t\u003cqueries\u003e\n        \u003cintent\u003e\n            \u003caction android:name=\"android.support.customtabs.action.CustomTabsService\" /\u003e\n        \u003c/intent\u003e\n    \u003c/queries\u003e\n\u003c/manifest\u003e\n```\n\n### Step 6: Launch application\n\n**Visual Studio:** Press Ctrl + F5 to start\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcasdoor-net%2Fcasdoor-dotnet-maui-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcasdoor-net%2Fcasdoor-dotnet-maui-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcasdoor-net%2Fcasdoor-dotnet-maui-example/lists"}