Login, roles and authentication through existing REST API

Hi guys,

We are building an app that consumes an existing REST API and want to:

  • Login using the account/api/token mechanism of this REST API
  • Consume REST API calls (e.g.: GET), passing the token gathered from the above login

We 've checked your CustomSecurity.cs found at your GitHub page and while it serves its purpose for adding and removing users among others, it does not do the above.

Could you please guide us as to what steps need to be taken in order to login using the above endpoint (e.g.: what should be the Action property of the LoginForm instead of /Account/Login) and how to setup the data for authentication?

Thanks!

Hi @goatofrafin,

Radzen's security relies on ASP.NET Core Identity which works with a database by default. Other providers are supported out of the box (such as Azure AD). Authentication through REST API isn't supported though. I am afraid we can't help you with the implementation. You probably need to implement entirely custom security and login instead of using the ones Radzen (and ASP.NET Core) provide.

You can add a custom API key to a REST data source method by specifying some of the provided partial methods. Here is an example:

   public partial class YourService
   {
       partial void OnGetSales(HttpRequestMessage requestMessage)
       {
           var uriBuilder = new UriBuilder(requestMessage.RequestUri);

           var queryString = HttpUtility.ParseQueryString(uriBuilder.Query);
           queryString["access_token"] = "<access token>";
           uriBuilder.Query = queryString.ToString();

           requestMessage.RequestUri = uriBuilder.Uri; 
       }
   }