OAuth2.0 - Authorization code grant

Can we do this for Blazor yet?

Trying to connect like so:
http://sparkplatform.com/docs/authentication/openid_connect_authentication

Also, I don't see Custom Query Parameters on Rest service config. Is that not available in Blazor yet?

Either the flow isn't supported or I cannot add the redirect_uri parameter or both.

Any workarounds?

TIA,
Josh

Our help article uses Spotify's code grant which seems to work fine.

Also, I don't see Custom Query Parameters on Rest service config. Is that not available in Blazor yet?

Yes, custom query parameters are not supported. We are not really sure how ASP.NET supports that.

Either the flow isn't supported or I cannot add the redirect_uri parameter or both.

Radzen generates code which automatically sets CallbackPath which maps to redirect_uri.

services.AddHttpClient();
services.AddAuthentication()
        .AddCookie("SpotifySignInScheme")
        .AddOAuth("Spotify", options =>
        {
            options.AuthorizationEndpoint = Configuration["Spotify:AuthorizationEndpoint"];
            options.TokenEndpoint = Configuration["Spotify:TokenEndpoint"];
            options.ClientId = Configuration["Spotify:ClientId"];
            options.ClientSecret = Configuration["Spotify:ClientSecret"];
            options.CallbackPath = new PathString("/spotify-callback");
            options.SaveTokens = true;
            options.SignInScheme = "SpotifySignInScheme";
        })

Thanks. I have not seen that article. Looking for it now.

So looking at your code, I believe I may be able to get it to work, however, I cannot get past the data config infer so there is no generated code.

This is an OData service having OAuth2 openid. Seems when I click Next, Radzen requests $metadata and gets 401 response, then a blank auth popup but no other requests are made.

It should:

GET https://sparkplatform.com/openid/authorize?response_type=code&client_id=<XX>&scope=openid&redirect_uri=https%3A%2F%2Fsparkplatform.com%2Foauth2%2Fcallback HTTP/1.1

Any ideas?
TIA,
Josh

Yeah, if the $metadata is also behind OAuth Radzen won't be able to retrieve it and infer the data source. I am afraid this isn't supported at the moment. You may have to use a REST data source which doesn't request $metadata.

Thanks for your reply. It would be swell if $metadata request would authenticate first. It acts like it’s try to do so but my OAuth isn’t working.

I have tried rest and have run into the redirect_url isn’t registered so I’ll see if the providers are willing register localhost.

I noticed the RadZen AzureAD scheme uses OpenIdConnect. I think I may need that for this service but not sure. I had to set the authenticationBuilder options.MetadataAddress in Startup.cs. Is there a supported way of customizing startup?

thanks

Is there a supported way of customizing startup?

Yes, here is the related documentation.

1 Like