RestClient and SSO, is it supposed to work?

Appreciate the suggestion, but as mentioned the source code to RestClientBuilder makes it pretty clear it never was setup to work with AzureAD from a session object… And anyway I’m out of time for this issue, customer will embed username and password in the customization and we’ll leave it there…

The code I just posted should get you the token from the current session which is a little less crappy.

2 Likes

Thanks Jose, I will keep it in mind… But between the debugging time, the week lost to the support black hole, and that it’s Friday 13th…

GIF by SkySlope

Thanks Jose.

1 Like

Never had to use that before, but I would have assumed that would have been available for direct
reference. Guess not.

Or did you just make that so you could use it anywhere?

^ that also its easier to reflect a type from the Dll than it is from a reference class. I would have had to back my way into the parent Assembly of a referenced class seemed like more work than just re-loading the assembly by name since its in the CWD anways.

This class is private internal
Epicor.ServiceModel.Wcf.Security.AuthenticationWcf

So I had to instantiate it from the assembly reference always :unamused:

2 Likes

I’m pretty sure there is a secrets management library/table Epicor has you can use to store those creds.

You sneaky beautiful bastard.

I can’t wait to understand this part of Epicor. I get it from like high high high level, but I can’t wait to actually build something that uses these methods.

season 2 shrug GIF by Fox TV

Hugo, I swallowed the red pill a long time ago. Still training and learning though.

no you dont understand the sandlot GIF

1 Like

Hahaha

I understand the code, and what he did.
I still don’t understand how he got there.

1 Like

Technically, AzureAD only needs accessTokenFunc to be setup and RestClientBuilder does this, so what exactly do you mean by “it never was setup to work with AzureAD”?

2 Likes

Did you try the code from @josecgomez ? The line that gets the accessTokenFunc is the one you care about. For Azure AD, that has to be non-null. If it is null than it assumes it is not token based.

@HLalumiere, if you put a try/catch around your “var restClient…” line, you should be able to get the full stack trace. At least that would narrow down where the exception is coming from.

2 Likes

Thanks for providing the code, Hugo. This issue has been fixed and the fix will ship with 2023.2.

3 Likes

Hey @josecgomez,
Can this be used in a customization using the RestSharp Lib which Epicor ships with the base product? I can not see an option to set the UseToken authentication option. Do we have to create a new RestClient differently from what @HLalumiere has posted?

Pardon my ignorance,

But Can’t you do something like

var client = new RestClient();
client.Authenticator = new NtlmAuthenticator();

Maybe not a long-term solution…