Authenticating with Auth0 from PowerShell or C# Console Application without Web Browser or JavaScript

We are an existing Auth0 customer. We use Auth0 to authenticate on our Web Application with AAD, SAML, Google and Microsoft. Once authenticated, the browser has the JWT. Our Web Application passes the JWT in the authorize header for every Web API.

We want to be able to use our Web API from PowerShell, C# Console App or similar without needing a Web Browser or JavaScript. In order to use the API, one must authenticate.

Rather than coding an API key, we would like some kind of prompt for username/password. Not in a web browser but rather similar to calling the “Login-AzureRMAccount” when managing Azure from PowerShell.

It would prompt for username and password. Auth0 would perform the “authentication dance” with whichever provider (AAD, Google, Microsoft, etc.) and give us back the token once authentication succeeds. Just like it does through JavaScript and the Web Browser.

While Auth0 has a managed username/password system, we wish to use AAD, Google, Microsoft, Facebook, etc. Any of the providers we use for authentication the Web Application.

We do not want to involve a web browser or GUI at all. Purely REST calls.

I’ve looked through the documentation and examples but haven’t found what I’m looking for. I found the example in doing it for a Universal app or WPF. But both of these seem to use an existing Auth0 NuGet package that has the UI backed in. My guess is that the UI wraps a web browser, which is not what we’re after.

Is this possible and, if so, are there any samples available?

Many thanks

  • Shaun

Hey there @shayward , I am currently researching this for you and will get back to you with an answer. Thanks!

I wanted to touch base with you @shayward and let you know that after talking with support There is a c# snippet for doing a client credentials grant on this page: Call Your API Using the Client Credentials Flow

We’ve had team members do it in a C# CLI and it does work, however if you’re not going to redirect to a sign-in page then you will need to use a client side library such as GitHub - auth0/auth0.net: .NET client for the Auth0 Authentication & Management APIs.

It’s important to note that Client Credentials won’t work for AAD, Google, Microsoft, Facebook as a browser interaction will be needed.

Please let me know if this helps answer your question. Thanks.

Thanks so much, James.

It does answer my question. It looks like we won’t be able to do AAD because the browser is needed. This is what I expected.

Many thanks again.

  • Shaun

No problem, I’m glad we could help!

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