Blazor Web Assembly Standalone OIDC

26 Views Asked by At

I'm trying to call OIDC, ID.Me, to handle Authorization.

    public static async Task Main(string[] args)
    {
        var MyAllowSpecificOrigins = "_myAllowSpecificOrigins";

        var builder = WebAssemblyHostBuilder.CreateDefault(args);
        builder.RootComponents.Add<App>("#app");
        builder.RootComponents.Add<HeadOutlet>("head::after");

        ...

        builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });

        builder.Services.AddOidcAuthentication(options =>
        {
            builder.Configuration.Bind("IDMe", options.ProviderOptions); 
            options.ProviderOptions.DefaultScopes.Add("openid");
        });

        await builder.Build().RunAsync();
    }

https://developers.id.me/documentation/federated-protocols/oidc

Within my wwwroot/appsettings.Development.json I have the following:

"IDMe": {
    "Authority": "https://api.idmelabs.com/oauth/authorize?client_id=CLIENT_ID&redirect_uri=REDIRECT_URI&response_type=code&scope={openid SCOPE}&state=optional",
    "ClientId": "XXXXXXXXXXXXXXXXXXXXXXXX",
    "PostLogoutRedirectUri": "https://localhost:44370/authentication/logout-callback",
    "RedirectUri": "https://localhost:44370/authentication/login-callback",
    "ResponseType": "code"
  }

When I attempt to do this I get a CORs Error.

Access to XMLHttpRequest at 'https://api.idmelabs.com/oauth/authorize?client_id={XXXXXX}&redirect_uri=https://localhost:7044&response_type=code&scope=military&state=optional/.well-known/openid-configuration' from origin 'https://localhost:7044' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Is there a way to get this CORS error to go away on my local? I only see solutions for a server.

0

There are 0 best solutions below