Search code examples
c#oauth-2.0oauthuipathuipath-orchestrator

How to authenticate using OAuth 2.0 with `authentication_code` grant flow type from a C# executable?


I'm working on a C# command line tool which automates some deployment tasks by sending requests to the API of an on-premise installation (in this specific case UiPath Orchestrator).

I've used until now bearer token authentication, which is being phased-out and need to move to OAuth 2.0 for authentication on the respective on-premise setup.

So far I've found some examples on how to authenticate using OAuth 2.0 with client_credentials grant flow type and have been able to successfully implement it myself:

The problem is that in my specific case client_credentials grant flow type is allowing the user to access too many resources and need to use instead authorization_code grant flow type, which lets the user access only allowed resources.

Would appreciate some simple/basic code snippets for authorization_code grant flow type, since so far found only the following examples, which I'm struggling to fully understand and not sure if those are applicable for my specific case:


Solution

  • Console apps do interactive logins using the system browser, in the same manner as desktop apps. There are two options to listen for the login response, reflected in these small C# code samples:

    For further info on concepts, and a couple of Node.js apps you can run locally, see my desktop blog posts, starting here.