PayPal Transaction Search API: PERMISSION_DENIED, No Permission for the requested operation

You need the scope https://uri.paypal.com/services/reporting/search/read .. if it’s not there in the oauth2 response, double check your REST App’s permissions. Refreshing an access token Existing access tokens are cached for 9 hours–so if you already requested an API token and then just added this permission to your app, it can take up to 9 hours … Read more

Update-Database command is not working in ASP.Net Core / Entity Framework Core because object in database already exists

There is no -IgnoreChanges currently in EF Core (see here) but you can achieve the equivalent by commenting out all the code in the Up() method and applying the migration. This will take a snapshot of the current model state so that subsequent migrations will only include changes from that point forward. So if you … Read more

ASP .NET Core default language is always English

You are setting “arabic” as DefaultRequestCulture but DefaultRequestCulture is used if none of the built-in providers can determine the request culture. The default providers are: QueryStringRequestCultureProvider CookieRequestCultureProvider AcceptLanguageHeaderRequestCultureProvider Most likely the culture is determined from the Accept-Language HTTP header that the browser is sending. You have to remove the AcceptLanguageHeaderRequestCultureProvider in order to fallback to … Read more

Formatting DateTime in ASP.NET Core 3.0 using System.Text.Json

Solved with a custom formatter. Thank you Panagiotis for the suggestion. public class DateTimeConverter : JsonConverter<DateTime> { public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { Debug.Assert(typeToConvert == typeof(DateTime)); return DateTime.Parse(reader.GetString()); } public override void Write(Utf8JsonWriter writer, DateTime value, JsonSerializerOptions options) { writer.WriteStringValue(value.ToUniversalTime().ToString(“yyyy’-‘MM’-‘dd’T’HH’:’mm’:’ssZ”)); } } // in the ConfigureServices() services.AddControllers() .AddJsonOptions(options => { … Read more

Get claims from a WebAPI Controller – JWT Token,

You should be able to retrieve a claims like this within your controller var identity = HttpContext.User.Identity as ClaimsIdentity; if (identity != null) { IEnumerable<Claim> claims = identity.Claims; // or identity.FindFirst(“ClaimName”).Value; } If you wanted, you could write extension methods for the IPrincipal interface and retrieve claims using the code above, then retrieve them using … Read more

Unable to resolve service for type ‘Microsoft.AspNetCore.Identity.UserManager` while attempting to activate ‘AuthController’

You need to use the same user data model in SignInManager, UserManager and services.AddIdentity. Same principal is true if you are using your own custom application role model class. So, change services.AddIdentity<IdentityUser, IdentityRole>(options => { options.User.RequireUniqueEmail = false; }) .AddEntityFrameworkStores<Providers.Database.EFProvider.DataContext>() .AddDefaultTokenProviders(); to services.AddIdentity<Automobile.Models.Account, IdentityRole>(options => { options.User.RequireUniqueEmail = false; }) .AddEntityFrameworkStores<Providers.Database.EFProvider.DataContext>() .AddDefaultTokenProviders();