Hi guys I’ve tried to add app_metadata to accessToken but without any luck.
My app is Blazor(Server&Client)
Things I have tried add successfully app_metadata to IDToken but now in AccessToken
Actions → Flow → Login
exports.onExecutePostLogin = async (event, api) => {
const namespace = 'IKActionFlows';
api.accessToken.setCustomClaim(`${namespace}/app_metadata`, event.user.app_metadata);
api.idToken.setCustomClaim(`${namespace}/app_metadata`, event.user.app_metadata);
};
Auth Pipeline → Rules
function addAppMetadataToAccessToken(user, context, callback) {
var namespace = 'IKAuthPipeline';
context.accessToken[namespace + 'app_metadata'] = user.app_metadata;
return callback(null, user, context);
}
This is my Program.css of Client(BlazorWASM)
builder.Services.AddOidcAuthentication(options =>
{
builder.Configuration.Bind("Auth0", options.ProviderOptions);
options.ProviderOptions.ResponseType = "code";
options.ProviderOptions.AdditionalProviderParameters.Add("audience", builder.Configuration["Auth0:Audience"]);
});
This is my Program.cs for Blazor(Server)
appBuilder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(JwtBearerDefaults.AuthenticationScheme, c =>
{
c.Authority = $"https://{appBuilder.Configuration["Auth0:Domain"]}";
c.TokenValidationParameters = new Microsoft.IdentityModel.Tokens.TokenValidationParameters
{
ValidAudience = appBuilder.Configuration["Auth0:Audience"],
ValidIssuer = $"https://{appBuilder.Configuration["Auth0:Domain"]}"
};
});
Can anyone give me any clue what I do wrong ? Thanks