"UnAuthorized" error when attempting to publish a project to Sonatype Nexus repository

How to resolve "Unauthorized" error, when an API key is passed to publish a project/library to Sonatype Nexus nuget repository?

Though an API key is available, there is an additional configuration that needs enabling to allow API key based authentication. This is activating the Nuget API-Key Realm on the particular repository, to allow API key based authentication.

Without the above setting, the API key based authentication will not work. If the issue still persists after enabling the above setting, then resetting/creating a new API key is recommended to be done, and then update the new API key while publishing from UiPath Studio’s publish screen.

More details regarding this particular property can also be found at https://help.sonatype.com/repomanager2/.net-package-repositories-with-nuget/deploying-packages-to-nuget-hosted-repositories