# Blazor WASM Security Odata get token

**URL:** <https://forum.radzen.com/t/blazor-wasm-security-odata-get-token/10067>\
**Category:** Blazor WebAssembly\
**Created:** [February 7, 2022, 2:15pm UTC](https://forum.radzen.com/t/blazor-wasm-security-odata-get-token/10067 "2022-02-07T14:15:34Z")\
**Posts on this page:** 2\
**Page:** 2

<div class="post-metadata">

**Author:** ![korchev](https://forum.radzen.com/user_avatar/forum.radzen.com/korchev/32/4_2.png) [@korchev](https://forum.radzen.com/u/korchev)\
**Post date:** [February 16, 2022, 7:39am UTC](https://forum.radzen.com/t/blazor-wasm-security-odata-get-token/10067/21 "2022-02-16T07:39:59Z")

</div>

It says that for the example purpose they will use the in memory store:

> For this document we will use the in-memory version of the client store. You can wire up the in-memory store in `ConfigureServices` via the `AddInMemoryClients` extensions method.

I am not sure if this is mandatory for using external clients or not and searching online didn't yield any definitive answer.

I found however this in the Microsoft documentation: [Use Identity to secure a Web API backend for SPAs | Microsoft Learn](https://docs.microsoft.com/en-us/aspnet/core/security/authentication/identity-api-authorization?view=aspnetcore-6.0#application-profiles)

It shows that there are predefined IdentityServer profiles (whatever that means). Not sure if this helps in any way though.

Lastly a lot of .NET services support the `services.Configure` method for further configuration. E.g. in the **OnConfigureServices** partial method you can try:

```auto
services.Configure<ApiAuthorizationOptions>(options => options.Clients.Add(...))

```

---

<div class="post-metadata">

**Author:** ![MarkusW](https://forum.radzen.com/letter_avatar_proxy/v4/letter/m/7c8e57/32.png) [@MarkusW](https://forum.radzen.com/u/MarkusW)\
**Post date:** [February 16, 2022, 9:58am UTC](https://forum.radzen.com/t/blazor-wasm-security-odata-get-token/10067/22 "2022-02-16T09:58:04Z")

</div>

Adding the client to the appsettings does not work for me.

But I added following code to the startup.costum.cs and it is working. Now I have a solution without adding startup.cs to the ignore list. Thanks for the help 🙂

```auto
services.Configure<ApiAuthorizationOptions>(options =>
                options.Clients.Add(new IdentityServer4.Models.Client()
                {
                    ClientId = "client",
                    AllowedGrantTypes = GrantTypes.ResourceOwnerPassword,
                    AccessTokenType = AccessTokenType.Jwt,
                    ClientSecrets =
                    {
                        new Secret("secret".Sha256())
                    },
                    // scopes that client has access to
                    AllowedScopes = { "TestwbaSecurity.ServerAPI openid profile" }
                }));

```

[Previous page](https://forum.radzen.com/t/blazor-wasm-security-odata-get-token/10067.md?page=1)
