public IAsyncOperation InitOAuth(string username, string password, string clientId, string clientSecret = null, string realm = null, string appName = null, string scopeSeparator = ":", bool usePKCE = false, Dictionary <string, string> aditionalQueryStringParams = null, bool scope_offline = false) { String[] scopes = null; if (scope_offline) { scopes = new string[] { "offline_access" }; } else { scopes = new string[] { }; } var tokenUrl = TokenPath ?? "https://sso.simva.e-ucm.es/auth/realms/simva/protocol/openid-connect/token"; var authUrl = AuthPath ?? "https://sso.simva.e-ucm.es/auth/realms/simva/protocol/openid-connect/auth"; var done = new AsyncCompletionSource(); OpenIdUtility.LoginWithROPC(username, password, authUrl, tokenUrl, clientId, null, string.Join(scopeSeparator, scopes)) .Then(authInfo => { AuthorizationInfo = authInfo; done.SetCompleted(); }) .Catch(error => { done.SetException(new ApiException(500, error.Message)); }); return(done); }