I have an existing .NET Framework API that uses the built-in OWIN token stuff.
A client can request a new API access token (client_credentials) with their client_id and client_secret. They can optionally pass in a scope e.g. scope=account:{guid}. The scope value is then parsed so that we can store the account id {guid}
In OpenIddict, I have setup a scope called account like so:
options.RegisterScopes("account");
I have also added that scope to the database like so:
var scopeManager = scope.ServiceProvider.GetRequiredService<IOpenIddictScopeManager>();
if (await scopeManager.FindByNameAsync(CommonParameters.AccountScope) == null)
{
await scopeManager.CreateAsync(new OpenIddictScopeDescriptor
{
Name = CommonParameters.AccountScope,
});
}
When I make a new access token request like so:
const string SCOPE = "account:00000000-0000-0000-0000-000000000000";
var response = await client.RequestClientCredentialsTokenAsync(new ClientCredentialsTokenRequest
{
Address = configuration.TokenEndpoint,
ClientId = CommonParameters.ClientId,
ClientSecret = CommonParameters.ClientSecret,
Scope = SCOPE
});
It returns invalid_scope. Is there a way to have scopes containing parameters that can be parsed and the parameters be stored somewhere? I don't want to have to set them up as individual scopes for each account id.