This repository was archived by the owner on Apr 17, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Problems with authentication when it is started by an UDF #1
Copy link
Copy link
Open
Description
Hi Shawn,
Thanks for the great example. It has saved me a lot of time, manly due to the SynchronizationContext...
I'm using your sample, but integrating it to excel using Excel DNA, and it is working almost as i wanna.
I have a ribbon, with an Auth button. If I Click this button prior to add any UDF on the worksheets that relies on the authentication, everything works perfectly
If, i add the UDF prior to authenticate, i was expecting the Auth0 pop up to show so i can authenticate, but this doesn't happen.
Let me provide some code so things are clearer..
private async Task Login()
{
AuthStatus = AuthenticationStatus.Authenticating;
if (SynchronizationContext.Current == null)
SynchronizationContext.SetSynchronizationContext(new WindowsFormsSynchronizationContext());
_auth0Client = new Auth0Client(_auth0Options);
var loginResult = await _auth0Client.LoginAsync();
if (loginResult.IsError)
{
AuthStatus = AuthenticationStatus.NotAuthenticated;
}
else
{
AuthStatus = AuthenticationStatus.Authenticated;
}
}
public async Task<bool> DoSomehing(string data)
{
if (AuthStatus== AuthenticationStatus.NotAuthenticated)
await Login();
if (AuthStatus== AuthenticationStatus.Authenticated)
{
// Some calc..
return true;
}
else
return false;
}
[ExcelFunction(IsThreadSafe = true, IsExceptionSafe = true)]
public static async void DoSomethingUDF(
[ExcelArgument(AllowReference = false)] string data,, ExcelAsyncHandle asyncHandle)
{
if (ExcelDnaUtil.IsInFunctionWizard())
asyncHandle.SetResult("No preview available on Function Wizard");
ExcelAsyncHandle.SetResult(await Publish(instrument, asyncHandle));
}
Do you have any clues??
Thanks a lot and thanks again for the sample!
Metadata
Metadata
Assignees
Labels
No labels