A MAUI sample application that uses Okta for authentication
- Create an Okta account, also know as an organization, see Developer Signup.
- In your
Okta Developer Console
add an application; follow the directions at Set up your Application and accept the defaults. - In your
Okta Developer Console
register your application's login and logout redirect callbacks, see Register Redirects. - Configure your application to use the values registered in the previous step, see Configure Your Application
- Go to Visual Studio (I used VS 2022 Community Edition) and update the
OktaClientConfiguration
settings with your application details in theMauiProgram.cs
:
var oktaClientConfiguration = new Okta.OktaClientConfiguration()
{
// Use "https://myOktaDomain.com/oauth2/default" for the "default" authorization server, or
// "https://myOktaDomain.com/oauth2/<MyCustomAuthorizationServerId>"
OktaDomain = "https://myOktaDomain.com",
ClientId = "<MyClientId>",
RedirectUri = "myapp://callback",
Browser = new WebBrowserAuthenticator()
};
- Start an Android emulator of your choice.
Note: This sample only implements the Android platform. You can go ahead and add the bits corresponding to the platform you want to try.
To register redirect URIs do the following:
- Sign in to your
Okta Developer Console
as an administrator. - Click the
Applications
tab and select your application. If you need to set up your application see Set up your Application. - Ensure you are on the
General
tab, then go toGeneral Settings
and clickEdit
. - Go to the
Login
section. - Below
Login redirect URIs
click theAdd URI
button. - Enter a value appropriate for your application, this example uses the following:
myApp://callback
- Below
Logout redirect URIs
click theAdd URI
button. - Enter a value appropriate for your application, this example uses the following:
myapp://callback
- Click
Save
.