Xamarin Forms authentication with Xamarin.Auth

I am trying to authenticate using Okta in my xamarin forms project with the Xamarin.Auth library.
I have setup an Okta account as follows:

ClientID:
Client authentication: Use PKCE
Okta_domain: dev-xxxxxx.okta.com
Allowed_grant_types: Authorization Code
Login_redirect_URIs: com.okta.dev-xxxxxx:/callback
Logout_redirect_URIs: com.okta.dev-xxxxxx:/
Initiate_login_URI: com.okta.dev-xxxxxx:/callback

From my xamarin app loginViewModel.cs page I am using the above as follows;
Scopes = “openid, email”

var authenticator = new OAuth2Authenticator(ClientID,
Scopes,
new Uri(Okta_domain),
new Uri(Login_redirect_URIs),
null,
false);

var Presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter();
Presenter.Login(authenticator);
authenticator.Completed += OktaAuthenticator_Completed;

The above seems to work, it allows me
[image] - (Okta authentication page)

The problem is after I get
[image] -
Authentication Error e.Message=Invalid state from server. Possible forgery!

I’m guessing that is something wrong in my input or that I am missing something. Please advise.

Thanks

I saw these two relevant discussions with work arounds for the error with Xamarin.auth:

Does it work for you ?

Thank you very much. The solution worked. It raises another issue, I will post on a separate thread

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.